OpenGL Application displays only 1 frame
Posted
by
Avi
on Game Development
See other posts from Game Development
or by Avi
Published on 2012-03-03T23:26:22Z
Indexed on
2012/04/03
11:42 UTC
Read the original article
Hit count: 244
EDIT: I have verified that the problem is not the VBO class or the vertex array class, but rather something else.
I have a problem where my vertex buffer class works the first time its called, but displays nothing any other time its called. I don't know why this is, and it's also the same in my vertex array class. I'm calling the functions in this order to set up the buffers:
- enable client states
- bind buffers
- set buffer / array data
- unbind buffers
- disable client states
Then in the draw function, that's called every frame:
- enable client states
- bind buffers
- set pointers
- unbind buffers
- bind index buffer
- draw elements
- unbind index buffer
- disable client states
Is there something wrong with the order in which I'm calling the functions, or is it a more specific code error?
EDIT: here's some of the code
Code for setting pointers:
//element is the vertex attribute being drawn (e.g. normals, colors, etc.) static void makeElementPointer(VertexBufferElements::VBOElement element, Shader *shade, void *elementLocation) { //elementLocation is BUFFER_OFFSET(n) if a buffer is bound switch (element) { .... glVertexPointer(3, GL_FLOAT, 0, elementLocation); //changes based on element .... //but I'm only dealing with } //vertices for now }
And that's basically all the code that isn't just a straight OpenGL function call.
© Game Development or respective owner