I have been trying to make an asteroids clone using openGL and have gotten totally stuck on a segmentation error I am unsure how to fix. It seems to happen on the usage of the function glGenBuffersARB(). If I comment out the lines using the vertexbuffer, the program compiles and runs fine (but obviously with nothing rendered). I am using the minGW compiler on eclipse with the gdb debugger and trying to use extensions so I can support versions of OpenGL earlier than 1.5.
glGenBuffers(1, &_VertexBufferObject);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, _VertexBufferObject ); // Bind The Buffer
glBufferDataARB( GL_ARRAY_BUFFER_ARB, U8VertexCount*3*sizeof(GLfloat), quad,GL_STATIC_DRAW_ARB );
GLuints are declared as private in a header like this:
GLuint _VertexArrayObject;
GLuint _VertexBufferObject;
int U8VertexStride;
int U8VertexCount;
gdb traces are here: gdb trace
I have found a solution to the problem. It would appear that declaring and using an object was not working the way I had intended. I was declaring the objects as:
CObj Obj;
and calling draw like this:
Obj.Draw();
when I switched to declaring it as a pointer:
CObj * Obj;
and initialising it like this:
Obj = new CObj();
then using:
Obj->Draw();
started to work as i thought it should. I am unsure why this is the case and would appreciate it if anyone is able to clear this up for me.