PDA

View Full Version : Single IBO and Single VBO or terrain rendering



Mars_999
11-26-2007, 09:00 PM
I think and hope I am close to having this worked out, but I am not able to render the whole terrain correctly? I think I have it narrowed down to this

glVertexPointer(3, GL_FLOAT, vertexStride, BUFFER_OFFSET(0));
glDrawElements(GL_TRIANGLES, numberIndices, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));

the glVertexPointer() I need to somehow offset the BUFFER_OFFSET()

I have tried this

index = 0;
//loop here
glVertexPointer(3, GL_FLOAT, vertexStride, BUFFER_OFFSET(index)); glDrawElements(GL_TRIANGLES, numberIndices, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
index +=vertexStride;

but that doesn't work either??? I only get partially rendered terrain???

Thanks

soconne
11-27-2007, 12:42 AM
How big is your terrain? If you're using GL_UNSIGNED_SHORT, then the largest terrain you can have is 255 x 255. You can't have anything bigger. Try using GL_UNSIGNED_INT instead if you can.

Mars_999
11-27-2007, 01:20 AM
I am trying to use unsigned short to stay on the fast path as Nvidia suggests.

I am sure there is some way to use a single VBO and a single IBO and just offset the various pointers to render the mesh?

a IBO of say 33x33 patch size is well with in unsigned short range. I have a working unsigned int version, but that uses one large VBO with many many IBO's...

Dark Photon
11-27-2007, 06:43 AM
glVertexPointer(3, GL_FLOAT, vertexStride, BUFFER_OFFSET(0));
glDrawElements(GL_TRIANGLES, numberIndices, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
This looks wrong. Surely your indices and your vertex data don't live at the start of the same buffer?

Zengar
11-27-2007, 07:17 AM
This are different buffers. DrawElements takes the currently bound ekement array buffer, while *Pointer takes the vertex array buffer.

Dark Photon
11-27-2007, 07:56 AM
This are different buffers.
Right, thanks for the correction. Slipped my mind.