Results 1 to 4 of 4

Thread: Depth Buffering Question!

  1. #1
    Member Contributor
    Join Date
    Aug 2000
    Webster, Ma 01570

    Depth Buffering Question!

    Hi Gang,
    Need some clarification on how Depth Buffering works in the case where the Z values for two objects being drawn are the same value. Does the object being drawn second go on top of the object drawn first? When I tried to test this situation, it looked like the two objects "blended" together, with the second object intersecting the first object in some spots. Is there w way that I can get the second object to lay directly on top of the first (without using a offset for the Z axis)?

    For instance my first object it a Sphere (actually a globe) and I am trying to draw a lat/lon grid on top of the globe, but I don't want any space between the globe and the lat/lon grid.

    so this is what I do (in theory - not real code!)
    Code :
    gluSphere(globe_, globeRadius, 48, 48);
    // Draw Lat/Lon takes in a radius value
    Like I said earlier - keeping the radius of both objects the same seems to make the objects blend together, with the lat/lon grid intersecting through the globe in some areas.

    if I do the following, I solve the intersecting problem, but the lat/lon grid seems to "float" above the globe (i.e. you can see a space between the grid and the globe).

    Code :
    gluSphere(globe_, globeRadius, 48, 48);
    // Draw Lat/Lon takes in a radius value
    drawLatLon(globeRadius + 0.1);
    Any ideas? Comments?


  2. #2
    Member Newbie
    Join Date
    Dec 2002
    Bucharest, Romania

    Re: Depth Buffering Question!

    What you're talking about is called z-fighting.
    You could try using 0.01 (or a value even lower instead of that 0.1).

  3. #3

    Re: Depth Buffering Question!

    I think you are looking for the glPolygonOffset() procedure. Check it out on page 251 of the Red Book . It is the very end of the 6th chapter. There is a section call "polygon offset". Use the blue arrow to the left of Chapter 6 to expand the chapter to subsections...then select the Polygon Offset section.

    - Halcyon

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Shreveport, LA, USA

    Re: Depth Buffering Question!

    Just be aware that you can use glPolygonOffset to offset polygons, not lines. So use it when you draw the sphere, not the lines.
    Another approach is to use the stencil buffer instead of polygon offset.

Similar Threads

  1. Depth buffering problem
    By theDancer in forum Vulkan
    Replies: 0
    Last Post: 07-22-2017, 09:15 AM
  2. FBO and Depth Buffering
    By Zulfiqar Malik in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 07-02-2005, 07:08 AM
  3. Depth Buffering Question
    By Roach in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 01-06-2003, 12:51 PM
  4. Depth Buffering - HELP !!
    By stockton in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-22-2002, 07:05 AM
  5. Depth Buffering
    By SpaceCadet in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 04-26-2000, 08:05 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