Question

In OpenGL, how can one cut a triangle shaped hole from a square? making the hole transparent.

I'm also using SDL, maybe it can be achieved with an SDL surface?

Was it helpful?

Solution

While doing it on a texture is truly the easier way out, if you need it to be a real shape, you might try using the GLUtesselator from GLU toolkit. See a tutorial for it here.

General usage is that you create a tesselator object, create two contours (the outer and the inner in a reverse direction) and the tesselator translates that into pure OpenGL commands. Of course if it's efficiency you're seeking you should implement or find some higher order system that operates on vertex buffers.

OTHER TIPS

You can use a texture and alpha blending: the texture would contain a transparent triangle. See this tutorial on blending.

EDIT: Of course alpha blending doesn't change the geometry. For that you need to perform treatments that are more complicated. See this tutorial on realtime CSG.

Reference: Constructive Solid Geometry

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top