Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How can I render to fbo out of QGLWidget::PaintGl
Forum Updated to NodeBB v4.3 + New Features

How can I render to fbo out of QGLWidget::PaintGl

Scheduled Pinned Locked Moved Game Development
1 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    h5nc
    wrote on last edited by
    #1

    Hi,

    I use QGLWidget for my game. I want to render my background into a fbo so that I don't need to repaint them every PaintGL call.
    My game update is called by a QTimer. After the update function I call QGLWidget::updateGL for repaint.
    My render code is mostly directly call gl functions without using QPaint.

    In my test run, if I put render to fbo codes in PaintGL function, it works. However if I move them to my update function, the result is weird: A "blank" thing (which should be the quad that contains the fbo texture) covers all previous rendered objects. The "blank" thing remains the same glClear color.

    Should I always put any render code, even not directly to the screen, within PaintGL function?

    All in 2D without depth.

    P.S. If I put updateGL() before my game update function, the result is correct. But is there a safer and better way to do this?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved