Thread: Depth Testing

  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
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Z buffer.

  3. #3

    Join Date
    May 2005
    Posts
    1,042
    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).
    I'm not immature, I'm refined in the opposite direction.

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, 07:40 PM
  4. OpenGL: Depth Testing, Matrixes, ect.?
    By Zeusbwr in forum Game Programming
    Replies: 8
    Last Post: 12-08-2004, 09:37 AM
  5. Blending and Depth Testing
    By Thunderco in forum Game Programming
    Replies: 2
    Last Post: 03-08-2004, 06:37 PM