I have a problem when I use buffers to cash memory on GPU. The program crash with code: 0xC0000005
mNumIndices is 36 and mNumVertices is 24.
Here´s my "bind" code:
glGenBuffers(1, &mElemBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mElemBuffer );
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mNumIndices * sizeof(GLuint),
mIndices, GL_STATIC_DRAW);
glGenBuffers(1, &mArrBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mElemBuffer );
glBufferData(GL_ARRAY_BUFFER, mNumVertices * sizeof(GLfloat), mVertices,
GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0 );
When I draw my box I use this code:
glBindBuffer(GL_ARRAY_BUFFER, mArrBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mElemBuffer);
...
glDrawElements( GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, mIndices );
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
If I comment the two glBindBuffer before rendering, it works. But then I dont use the buffers. Hmm ..
Please help me. New to OpenGL.
Btw, its OpenGLES 2.0. But that doesnt matter I think.
[Edited by - SimonS on January 20, 2009 10:59:13 AM]