I ran into an odd problem with the OpenGL function glGenBuffers (). I am writing a fairly simple application in which I use VBO declared as follows:
#include <QGLFunctions> #include <QGLWidget> class MyClass : public QGLWidget, protected QGLFunctions { GLuint vertexBufferObject; // ... GLuint makeBufferList(void); } GLuint MyClass::makeBufferList(void) { vertexBufferObject = 0; glGenBuffers(1, &vertexBufferObject); // <-- Here it crashes // ... load data and render return vertexBufferList; } MyClass::MyClass(QWidget* parent) : QGLWidget(parent), vertexBufferObject(0) { QGLContext* context = new QGLContext(this->format()); initializeGLFunctions(context); glInit(); } MyClass::~MyClass() { glDeleteBuffers(1, &vertexBufferObject); }
All this works great in Debug Build. The data is obtained beautifully and thatβs it, and the program ends correctly at the end. However, in Release Build, glGenBuffers () unloads the program. It does not just return 0 or does nothing, it works right when the function is called. But since the problem only occurs in Release mode, I cannot use the debugger to find out what is going wrong.
I am working on a Windows 7 system and developing in Qt 4.8.1. The compiler is the MSVC 2010 compiler (Qt SDK).
Does anyone have any suggestions that I could try?
// Edit:
It may be useful to know: I tried to compile the exact same code on a Mac using the GCC compiler (Qt SDK), and both Debug and Release Build work just fine. But in Windows 7 the problem persists.
source share