Hi there, I’m in the process of upgrading my application to use Qt 5 and come across a stumbling block. Previously I had used this code to give my GL widget a new GL context (the this pointer is the GL widget):
// Create a fresh OpenGL context and make it current.
QGLContext* newContext = new QGLContext(this->format(), this);
newContext->create();
newContext->makeCurrent();
this->setContext(newContext, NULL, true);
this->makeCurrent();
However it doesn’t appear to work anymore, instead it makes the GL widget have a grey background and then lots of OpenGL “Invalid Operation” errors whenever glGetError() is run. I’ve checked the QGLContext::create() and QGLContext::isValid() functions are returning true (they are) so I’m not sure where its going wrong. This method used to work for me in 4.7 and 4.8. If it makes any difference I’m using MSVC2012 and have compiled Qt with the “-opengl desktop” option. OpenGL rendering itself seems to work as I can render it fine before resetting the context, it’s only afterwards I can’t.
Is there an alternative way I should explore for achieving this? Thanks in advance. :)
↧