VBO/IBO Terrain Rendering Problem

Hello, I am having a heck of a time getting my head around vbo/ibo fully.
Right now my terrain is rendering wrong…it is rendering with two layers…when it should only have one.

The diagonal solid strips aren’t supposed to be there…only the triangles. This is causing me problems because it makes it so that the terrain appears to have two layers in some parts.

For example here is two screenshots of me inside of the terrain.
http://i274.photobucket.com/albums/jj265…/buscreeny5.jpg
http://i274.photobucket.com/albums/jj265/Erebel55/bugscreeny4.jpg

Here is a pastebin of how I create and draw my terrain.
http://pastebin.com/zCQZ2Cxe

Normally, I render my terrain with GL_TRIANGLE_STRIP. I am only using GL_TRIANGLES at the moment so that I can see what is going on easier.

Any help would be hugely appreciated…this has been bugging me for a while.

Thanks.

This didn’t make sense to me.

The diagonal solid strips aren’t supposed to be there…only the triangles.

Well at least it looks like your vertex attribute positions are right. Probably just have a problem getting the right index list (or index list order) for your triangles.

To help rule out that some of the triangles are facing the wrong way, try:

glDisable ( GL_CULL_FACE ) ;

If you see them now, you may just have the order of the triangle indices specified wrong. They should match whatever glFrontFace convention you have active (CCW by default).

Also, to see the verts you are sending down:

glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ;

Also, in case your normals are flipped for some reason, slap some code in your shader to flip the normals toward the eye (two-sided lighting tweak):

normal_eye *= float( dot( normal_eye, -vertex_eye ) >= 0 ) * 2. - 1.;

Probably should have used the faceforward built-in, but didn’t know about that at the time:

normal_eye = faceforward( normal_eye, vertex_eye, normal_eye );

Thank you very much for your reply.

I tried everything you suggested but the strips are still there…
Here is a screenshot showing this.
New Screenshot

CCW is active for glFrontFace. Thank you for the useful tips :slight_smile:

So, I’m assuming that my index order is wrong? :o

They weren’t intended to fix it. They were intended to help you see what is going on.

Here is a screenshot showing this.
New Screenshot

CCW is active for glFrontFace. … So, I’m assuming that my index order is wrong?

Kind of what it looks like, assuming this is supposed to be a regular grid of triangles. Looks like you’re missing indices for a bunch of triangles. Notice you can see in the white areas that there are no edges at all. Assuming this is with cullface off (and your shader isn’t turning the color to white), then looks like missing indices for certain triangles.

Try drawing a short patch of 10, 20, or however many triangles it takes to see the problem. Then incrementally subtract one triangle at a time from your rendering until you see the problem.