VBO Woes

Started by
13 comments, last by CyberSlag5k 19 years, 1 month ago
Quote:Original post by _the_phantom_
try switching that code to sizeof(_Vertex)*numVerts and sizeof(unsigned int)*numInd as i dont think that code is doing what you think it does..


Yup, tried that just after responding to your last post. No dice.

Quote:
oh, and using an unsigned short (whatever the gl type for that is, glushort i think) for indices is a much better idea, gfx cards can choke a bit on over 65K verts and you save half the space vs ints


I wish I could. Sadly, only the smallest of the objects I'm loading with this project are sub 65,000 polygons. The large ones near 200,000.

Thank you for your response, _the_phantom_.
Without order nothing can exist - without chaos nothing can evolve.
Advertisement
Ok, since it still is not working as it should, this is what I would change:

I would change the "sizeof(*vertlist) * numVerts" into "sizeof(vertex) * numVerts" where sizeof "vertex" would be (in this case) sizeof(float) * 6.

I would change the "sizeof(*indices) * numInd" into "sizeof(unsigned int) * numInd".

For the rendering I would call glDrawElements and not glDrawRangeElements, like this:
glDrawElements(GL_TRIANGLES,numInd,GL_UNSIGNED_INT,BUFFER_OFFSET(0));
where the macro BUFFER_OFFSET(0) would return 0.

I hope that this will help.
Thank you for your response, AxoDosS. And everyone else as well. Last night our local expert _the_phantom_ found the problem with my VBOs: I wasn't declaring a stride size for my interleaved array when calling the gl*Pointer() functions. They're working now, but they're incredibly slow. I'll be investigating that (and likely posting a question or two) this morning.

Thanks again everyone!
Without order nothing can exist - without chaos nothing can evolve.
My guess is that it's slow because the driver has to do a software fallback to support the 32 bit indices (afaik most hardware only supports up to 24 bit).
So my suggestion is to cut up your objects into submeshes of at most 64k vertices, and render everything with 16 bit indices. It is more compatible, faster, and as already pointed out, more compact aswell.
Thanks, AP. I'll give it a shot.
Without order nothing can exist - without chaos nothing can evolve.

This topic is closed to new replies.

Advertisement