Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: [SOLVED] Objects drawn in odd order

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    20

    [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.

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Objects drawn in odd order

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    20

    Re: Objects drawn in odd order

    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

    Thanks.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    20

    Re: Objects drawn in odd order

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •