Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How can I render to fbo out of QGLWidget::PaintGl
h5nc last edited by
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?