1. 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 :
```glEnable(GL_DEPTH_TEST);

// 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 :
```glEnable(GL_DEPTH_TEST);

// Draw Lat/Lon takes in a radius value

Thanks
Roach

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

Posting Permissions

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