Reputation: 426
As the title suggests, inside of Qt, I am unable to use, or call any OpenGL functions outside of QGLWidget functions like initializeGL()
, and paintGL()
.
I am trying to build a 3D model, after a slot from my QMainWindow
class is called. Everything appears to work fine, all of the vertices are loaded, however, when I try and draw my model, I get a NULL reference exception; which occurs, most often, when too few Vertexes are provided.
The same building function works when I use it in initializeGL()
.
Upvotes: 3
Views: 1340
Reputation: 1009
This is actually quite simple: outside of those functions, the QGLWidget's context is not current. You can make the context current by calling QGLWidet::makeCurrent(). A perhaps better way to get around this is to defer calling any GL functions to within paintGL, as that ensures that the context is current, and you don't risk messing with any other openGL stuff by changing the context.
Upvotes: 7