I am rendering a terrain and because the underside will never be seen I though face culling would bring a nice performance boost. I looked up a tutorial and came to these settings:
glCullFace(GL_FRONT);
glFrontFace(GL_CCW);
The problem is, that this is only working partially. The terrain is made out of quadrilaterals which each consist out of two right triangles and I only see one of the two triangles, if I use clockwise winding, I see the other triangle. I am using indices to safe memory and I have drawn out on paper how the windings of the indices should be but somehow it isn't working.
I generate my indices like this:
mapIndices[arrayIdx + 0] = i;
mapIndices[arrayIdx + 1] = i + 1;
mapIndices[arrayIdx + 2] = i + CHUNK_SIDE_LENGHT + 1;
mapIndices[arrayIdx + 5] = mapIndices[arrayIdx + 1];
mapIndices[arrayIdx + 4] = mapIndices[arrayIdx + 2];
mapIndices[arrayIdx + 3] = mapIndices[arrayIdx + 2] + 1;
Don't get confused over the CHUNK_SIDE_LENGHT + 1, I want CHUNK_SIDE_LENGHT triangles, so I need CHUNK_SIDE_LENGHT + 1 vertices for one row.
As I said, I have drawn this order on paper and the winding is correct but OpenGL doesn't like it. Could this have something to do with the index rendering?