subtracting polygons

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.

Thank you jide. I will give it a try.

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.

the simplest answer in that case would be “draw all other polygons without stencil test before the one with the hole”

Thank you RigidBody. I will give your suggestion a try.

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.

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”).