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: 210

Filed under:
|
|

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:

  1. enable client states
  2. bind buffers
  3. set buffer / array data
  4. unbind buffers
  5. disable client states

Then in the draw function, that's called every frame:

  1. enable client states
  2. bind buffers
  3. set pointers
  4. unbind buffers
  5. bind index buffer
  6. draw elements
  7. unbind index buffer
  8. 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

Related posts about opengl

Related posts about debugging