Hi, I’m having a problem with glDrawElements. I’m trying to render some triangle strips, which are stitched together with degenerate triangles into one very big strip. That is, if I have a strip ABCD and another strip EFGH, they become ABCDDEEFEFGH which creates the degenerate triangles CDD, DDE, DEE, EEF, EFE, FEF. Using the loop below, I get tiny filaments where the degenerate triangles are positioned and they flicker as the scene is animated:
gl.glCullFace( GL.GL_FRONT );
gl.glBegin( GL.GL_TRIANGLE_STRIP );
for ( int i = 0; i < iCount; i++ ){
vInd = indices.get( i );
nx = normalCoords.get( vInd + 0 );
ny = normalCoords.get( vInd + 1 );
nz = normalCoords.get( vInd + 2 );
vx = vertexCoords.get( vInd + 0 );
vy = vertexCoords.get( vInd + 1 );
vz = vertexCoords.get( vInd + 2 );
gl.glNormal3d( nx, ny, nz );
gl.glVertex3d( vx, vy, vz );
}
gl.glEnd();
When I try to render exactly the same buffer with glDrawElements (which I’d rather use), I get large triangles drawn where there should be only degenerate triangles:
gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexCoords );
gl.glEnableClientState( GL.GL_NORMAL_ARRAY );
gl.glNormalPointer( GL.GL_FLOAT, 0, normalCoords );
gl.glDrawElements( GL.GL_TRIANGLE_STRIP, iCount, GL.GL_UNSIGNED_INT, indices );
Why are the two methods producing different results; shouldn’t they be equivalent?
How should I set up my buffers to stitch together multiple triangle strips so that it can be used with glDrawElements? And out of curiosity, why are the filaments being produced in the first code example (shouldn’t degenerates just get culled straight away)?
Thanks for any light at all you can shed.