Search code examples
c++openglboolean-operations

Drawing a Circle on a plane, Boolean Subtraction - OpenGL


I'm hoping to draw a plane in OpenGL, using C++, with a hole in the center, much like the green of a golf course for example.

I was wondering what the easiest way to achieve this is?

It's fairly simple to draw a circle and a plane (tutorials all over google will show this for those curious), but I was wondering if there is a boolean subtraction technique like you can get when modelling in 3Ds Max or similar software? Where you create both objects, then take the intersection/union etc to leave a new object/shape? In this case subtract the circle from the plane, creating a hole.

Another way I thought of doing it is giving the circle alpha values and making it transparent, but then of course it still leaves the planes surface visible anyway.

Any help or points in the right direction?


Solution

  • I would avoid messing around with transparency, blending mode, and the like. Just create a mesh with the shape you need and draw it. Remember OpenGL is for graphics, not modelling.

    triangle mesh of a rectangle with a hole in it