[SOLVED] Objects drawn in odd order

Hi guys,

So I’m doing a lot of complicated things in my code, but what I have is a very simple problem that should be very basic, but I can’t figure out how to fix it for the life of me.

Basically what I have is a VBO that draws a bunch of cubes. This works fine. Then I rotate the scene to look at these cubes from different view points. This is where trouble starts. In certain views everything looks fine, but in other views back cubes get drawn over the front ones. Any clue how to fix this? Is it glDepthFunc? I tried it, but no help, if anything I get stranger results.

Thanks.

Do you enable depth test ?
glEnable(GL_DEPTH_TEST);

Do you request a depth buffer, with 24 bits precision ? And is your near clip plane far enough, and you far clip plane near enough ? Otherwise you will have too much imprecision in depth test.

well did enable the depth test, but I’m not sure how to set the near and far clip plane. Off to google I guess :slight_smile:

Thanks.

Got it fixed. My near plane was set too close. Basically having it close to 0 is not good. Changed it using gluPerspective() and now everything works like a charm.

Thanks ZbuffeR