View Full Version : subtracting polygons
02-07-2007, 02:35 AM
I am not sure where to put this question, but since I am not an expert at OpenGL I will try here.
If I have two polygons, one Outer and one Inner, and I want to remove the area of the Inner polygon from that of the Outer polygon (create a "hole" in the Outer polygon) what is the easiest way? Does OpenGL have a library call that can do this automatically?
Thanks in advance for any help or hints.
You can use the stencil buffer to do that. Or you can use a CSG library. It's somewhat easy in both cases.
02-07-2007, 06:02 AM
Thank you jide. I will give it a try.
02-07-2007, 06:14 AM
Please excuse my ignorance, but will the stencil buffer remove everything in its defined region or only the polygon on which you have it placed?
I would like the user to still be able to see other polygons that may be behind the polygon that is being stenciled (such as an open-top box).
Once again, thank you.
02-08-2007, 03:52 AM
the simplest answer in that case would be "draw all other polygons without stencil test before the one with the hole"
02-08-2007, 08:02 AM
Thank you RigidBody. I will give your suggestion a try.
02-16-2007, 03:05 AM
Some of the general shapes of the polygons with the "holes" appear to be complex. I am unfamiliar but what about using tessellation?
Does anybody have a link or some simple code that uses tessellation I could look at?
Thanks in advance.
02-16-2007, 06:41 AM
Here's a nice tutorial:
Some demos from the redbook (tesswind.c is in there):
I'm sure there are many other examples online (try a search for "opengl tesselation").
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.