Notice the huge difference between your
glVertexPointer(2, GL_FLOAT, sizeof(myVertex), (const GLvoid *)&myQuad[0].x);
and that page's
glVertexPointer(2, GL_FLOAT, sizeof(myVertex), NULL);
NULL is the start address of the VBO.
Help - Should I move to VBOs?
Ok - that makes sense
So now it looks like
But now I get a seg fault on
The page does mention that if you are using interleaved arrays - that you need to specify the stride in gl*Pointer.
Have I got sizeof(myVertex) right as the stride - The stride takes it from myQuad[0].x to the next coordindate myQuad[1].x - therefore the stride is the size needed to get to the start of the next vertex. Is that right??
Thanks for your help so far.
So now it looks like
glVertexPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(0)); //(const char *)&myQuad[0].x); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(sizeof(GLfloat) * 2)); //(const char *)&myQuad[0].s);
But now I get a seg fault on
glDrawArrays(GL_QUADS, 0, NUM_VERTS_SPLASH);
The page does mention that if you are using interleaved arrays - that you need to specify the stride in gl*Pointer.
Have I got sizeof(myVertex) right as the stride - The stride takes it from myQuad[0].x to the next coordindate myQuad[1].x - therefore the stride is the size needed to get to the start of the next vertex. Is that right??
Thanks for your help so far.
Usually in 2D games, especially when drawing just quads etc, your bottle neck will be fill rate, not bandwidth of vertex data or anything of that sort. 10,000 polygons is nothing for a video card these days, so VBO probably wont help you. Maybe at 100,000 polygons or more, you might see a 5% improvement in performance from immediate mode to VBO. once you hit the 1 million polygon mark, this is when you need to be doing VBO 100%.
I've done a few tests, and anything under 10k polygons, a display list or vbo won't make a difference.
But you can always test it out, make a key that switches you from vbo to display list to immediate and see if your fps changes. (using framerate isn't always the best indicator for performance gains or changes... if you fps is less than 100 in both cases you should be fine... but framerates in the 300+ range become inaccurate and shouldn't be used for comparisons)
[Edited by - ViperG on July 18, 2009 3:55:01 PM]
I've done a few tests, and anything under 10k polygons, a display list or vbo won't make a difference.
But you can always test it out, make a key that switches you from vbo to display list to immediate and see if your fps changes. (using framerate isn't always the best indicator for performance gains or changes... if you fps is less than 100 in both cases you should be fine... but framerates in the 300+ range become inaccurate and shouldn't be used for comparisons)
[Edited by - ViperG on July 18, 2009 3:55:01 PM]
Quote:Original post by snoutmate
Do you have the VBO bound before calling the gl*Pointer functions ?
Works !! Changing from
glVertexPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(0)); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(sizeof(GLfloat) * 2)); glBindBuffer(GL_ARRAY_BUFFER, splashVBOID);
to
glBindBuffer(GL_ARRAY_BUFFER, splashVBOID);glVertexPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(0)); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(sizeof(GLfloat) * 2));
Thank you for your help !
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement