View Full Version : Intersecting polygons and clipping
02-09-2007, 04:29 AM
Hi, I'm having a problem with intersecting polygons. The green and red triangles below represent a solid plane. What I would like to do is have the blue triangles stop rendering where they meet the red and green triangles so you can't see them below the red/green plane. The blue triangles are perpendicular to the red/green plane. I've tried every trick I could think of for the z-buffer but nothing I am doing is working. Can someone please point me in the right direction? Below is attached an image of the problem. Thanks!
02-09-2007, 04:34 AM
did you do all of the following:
- choose a pixelformat with depth buffer
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
02-09-2007, 04:40 AM
I did #2 and #3. How would I go about choosing the pixel format for the depth buffer?
02-09-2007, 07:05 AM
Did you create a rendering context?
02-09-2007, 07:59 AM
Yes I did. I also checked into things like PolygonOffset, Depth fuctions, alpha blending, etc. but to no avail. I'm guessing that the problem has something to do with the z-buffer but I feel I've exhausted all of my options. So I'm appealing to you guys.
glGetIntegerv (GL_DEPTH_BITS, &dbb);returns in dbb ?
02-10-2007, 01:36 AM
From your image it look like the blue triangles don't intersect the red-green at all, but are just in from of them. Am I missing something? Maybe you got wrong coordinates? What happen when you render the blue triangles first and the red-green last?
02-11-2007, 06:44 AM
If in your gluPerspective call you have the depth buffer range set unusually large (the last two arguments), that could happen due to unlucky rounding, I think.
02-12-2007, 03:51 AM
Originally posted by Zengar:
From your image it look like the blue triangles don't intersect the red-green at all, but are just in from of them. Am I missing something? Maybe you got wrong coordinates? What happen when you render the blue triangles first and the red-green last? Yes, I realize this. I'm able to mouse around and rotate things, so I am completely sure the blue triangles intersect exactly in the middle of the red and green triangles.
As for the gluPerspective, I have the numbers 1.0 and 1000.0 for the last two parameters.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.