Results 1 to 8 of 8

Thread: Display order with/without depth buffer

  1. #1
    Guest

    Display order with/without depth buffer

    Hi!

    I am developing a 3D board game, whose pieces are painted as spheres. For that the depth buffer has to be enabled ("glEnable(GL_DEPTH_TEST);"). And there are status informations displayed during the game, which must not be covered by any game element (p. e. spheres).
    I tried to achieve this effect by disabling the depth buffer while painting the status informations. But the spheres still covered the informations display, no matter if painting them before or after painting the spheres.

    Please help me solve this problem.

    Thanks in advance
    cndg

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

    Re: Display order with/without depth buffer

    Following method should work :
    - enable depth test
    - draw spheres
    - disable depth test
    - draw your status info, it should appear on top of everything previously drawn.

  3. #3
    Guest

    Re: Display order with/without depth buffer

    But your suggestion describes exactly what I did and it doesn't work. The spheres still cover everything.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Display order with/without depth buffer

    Did you initialize the window with a depth buffer?
    eg. in glut specify GLUT_DEPTH in glutInitDisplayMode

    Also, make sure your depthMask is correct in case you changed it somewhere. The initial value should work.

    Nico

  5. #5
    Guest

    Re: Display order with/without depth buffer

    hey cndg, what zbuffer's saying is that if you follow those steps, it will work. this is standard procedure for rendering game overlays (HUDs), nothing new. if you are following those steps, then there's a mistake somewhere in your code, not in the steps. as nico said, double check your code for innocent blunders

  6. #6
    Guest

    Re: Display order with/without depth buffer

    @-NiCo-: I only use GLUT when painting the spheres. The rest of my program is "GLUT-free". But the spheres itselves are rendered as I expect - so the depth buffer seems to be working correctly.
    Is "depthMask" the property with GL_ALWAYS, GL_LESS,...? If it is: I am not changing it.

    @bonehead: It was my first idea to render it that way (enable depth test - draw spheres - disable depth test - draw my status info) but it didn't work as I told. It is so easy - what could I have done wrong? But nevertheless I am going to check my code...

  7. #7
    Guest

    Re: Display order with/without depth buffer

    ...and did not find a wrong line.

  8. #8
    Guest

    Re: Display order with/without depth buffer

    I was able to solve the problem by using the stencil buffer (glStencilFunc and glStencilOp). First the stencil buffer has to be cleared with zeros. The status informations consist of letters. Where ever a letter depending to the status display is drawn the stencil buffer bits covered by the letter are replaced by ones. However the stencil test rules for spheres are a bit more restrictive. They forbid every sphere to change any bit in the stencil buffer. And they prescribe that no bit belonging to any sphere is painted where the stencil buffer bits contain ones. So the status display protects itself a hundred per cent.

Similar Threads

  1. display image in reverse order
    By jayaprakash in forum OpenGL: Windows
    Replies: 3
    Last Post: 02-03-2009, 10:28 AM
  2. Please Help: Objects Rendering in Reverse Depth Order
    By robosport in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-04-2006, 11:35 AM
  3. How to display contents of p-buffer depth buffer?
    By robosport in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 03-16-2004, 04:13 PM
  4. How to Read & Display the Depth Buffer's Contents
    By Olumide in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-14-2002, 03:51 AM
  5. why depth buffer save to image file can not display depth information
    By victorswan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-27-2001, 09:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean