Z-buffer

I am very new to OpenGL and have been tasked to help solve a problem here at work.

When we draw any objects, like a ship, using OpenGL code the object looks weird. (I wish I could show you a picture) The objects look somewhat ok if you look at them from the side view however; if you start to look at them from the top it looks weird. The top layers become transparent and you can only see the very bottom layer. Are we drawing the layers in the reverse order (top to back)? Is so what do I need to look at to fix the problem?

From what you described, it sounds like the order of vertices for some(or all) of the faces are the wrong way. If the vertices are entered in a clockwise fashion, but gl uses a counter-clockwise ordering to determine visibility, then you wont see your polygons.

Try reversing the order of your vertices.

As a simple test call glFrontFace with GL_CW and the GL_CCW to see which one works

[This message has been edited by bumby (edited 09-22-2003).]

Is your Z-buffering working correctly? If faces further away from the camera are being drawn over the top of the nearer ones, this is likely to be your problem.

You need to request a context with a Z-buffer (implementation dependent), enable depth testing (GL_DEPTH_TEST) and optionally set up your depth equation (glDepthFunc).

Note: You can save even more time here, and cull the polygons that are facing away from you in the first place. Enable face-culling (GL_CULL_FACE) and define a winding order (glFrontFace), as bumby says above.

It sounds to me like when you rotate the object, part of it gets clipped by the near clip plane.

Oh, so THIS is why Half-Life 2 is delayed…