Depth Testing

This is a discussion on Depth Testing within the Game Programming forums, part of the General Programming Boards category; Hello, I'm writing a simple 3d engine. It renders triangles and quads. However, now I'm having a hard time figuring ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Norway
    Posts
    16

    Depth Testing

    Hello,

    I'm writing a simple 3d engine. It renders triangles and quads. However, now I'm having a hard time figuring out how to do my depth testing. No polygons will ever intersect. I originally thought I could simply get the average z coordinate of all the polygon's vertices (the center of the polygon) and sort based on that. However this doesn't always work. For example, if I place two identical quads on top of each other, the bottom one has the same z coordinate even though it should be rendered behind the top quad.

    If someone could give me some advice I'd be very grateful.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,515
    Z buffer.
    Arrogance breeds bad code

  3. #3

    Join Date
    May 2005
    Posts
    1,038
    It seems like you're doing this from a pretty low level, so I'd also suggest reading up on the Painter's algorithm. The Painter's algorithm is basically an archaic alternative to a depth buffer (but a depth buffer is somewhat more straightforward to implement).
    You know what date is on this coin? 1958. It's been travelling twenty two years to get here.
    And now it's here.
    And I'm here.
    And it's either heads or tails.
    And you have to say...
    Call it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-23-2009, 06:20 PM
  2. Need some help...
    By darkconvoy in forum C Programming
    Replies: 11
    Last Post: 05-09-2009, 02:34 AM
  3. Simple 2D rubiks cube algorithm.
    By jeanmarc in forum Game Programming
    Replies: 19
    Last Post: 11-11-2008, 06:40 PM
  4. OpenGL: Depth Testing, Matrixes, ect.?
    By Zeusbwr in forum Game Programming
    Replies: 8
    Last Post: 12-08-2004, 08:37 AM
  5. Blending and Depth Testing
    By Thunderco in forum Game Programming
    Replies: 2
    Last Post: 03-08-2004, 05:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21