As Qt users know, using any OpenGL extension can be quite annoying. The way I worked was to extend the QGLFunctions class as follows:
class Object3D : protected QGLFunctions{ ... }
In order for Object3D to function correctly so that it can call functions such as glGenBuffer (), etc., you need to call
initializeGLFunctions(glWidget->context());
AFTER QGLWidget was created, otherwise it just crashes the application when it uses any extension functions. Although I can finally call "glGenBuffer ()" and others throughout the existence of Object3D, it seems to break down into an Object3D () call that contains a call to "glDeleteBuffer ()". I am sure that this particular call causes application crashes.
Does anyone know how to solve this problem? I suspect this is because the QGLWidget is deleted first before Object3D, so the QGLWidget context is missing. If so, how can I make sure that QGLWidget is deleted last, since QGLWidget is added to QMainWindow, which simply removes its children in the order in which they are added?
source share