PDA

View Full Version : OpenGLWidget: problem creating OpenGL recources outside of initializeGL



Zajo
15th March 2015, 06:54
I'm on Qt 5.4.0 on Windows. Using QOpenGLWidget, I need to postpone the creation of OpenGL buffers, etc. until after initializeGL has executed.

I call makeCurrent, then create buffers, etc. which works fine, but when paintGL is called I get OpenGL errors, as if the OpenGL handles I'm using to draw belong to a different context. Note that if exactly the same code executed from within initializeGL, I get no errors in paintGL.

So I downloaded the source code and traced into makeCurrent (since it is a void function and doesn't indicate success or failure, perhaps this should be added to the API), and observed that everything succeeds; and I've verified that the address of the context object is the same in the code that calls initializeGL and within the makeCurrent call.

Any idea what could be wrong?

Zajo
15th March 2015, 23:02
Answering my own question: it seems like there was some OpenGL client state enabled by the Qt code that calls my OpenGL rendering code, which interfered with my renderer. So, don't assume anything about the current state of the context when Qt calls paintGL.