Strange Clipping Issue in OpenGL
Question
I am very very new to OpenGL, so please bear with me. :) I'm working through NeHe's OpenGL tutorials, and I have developed my own version of Lesson 5, in which you rotate a 3D shape around the origin. I'm not sure what I did wrong, I copied the code nearly line-for-line, but I'm seeing strange overlaps in my surfaces.
Does anyone have any suggestions as to what would cause such an issue?
Solution 3
Wow, completely fixed it with one line:
gl.glEnable(GL.GL_CULL_FACE);
I have no idea what it does, but it wasn't mentioned in any tutorials I used, but my demo works perfectly now. Off to Google to figure out what that did. :D
OTHER TIPS
To me it looks like you are missing enabling the Depth buffer or maybe creating a framebuffer with a z-buffer. (this is similar to what Troubadour is writing)
glEnable(GL_DEPTH_TEST);
Looks like you've got an issue with the depth buffer. In particular it looks like each polygon is being drawn without regard to depth i.e. each fragment coming from the polygons is passing the depth test. This would mean that the polygons are simply drawn over each other in whatever order they happen to be rendered in.
Did you disable writing to the depth buffer with something like
glDepthMask( GL_FALSE )
by any chance?
If it's not that then did you remember to clear the depth buffer at the beginning of each frame? The Nehe tutorial starts with
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
which clears both the depth and colour buffers. Make sure you haven't got rid of the GL_DEPTH_BUFFER_BIT
part of that.
HTH