At first, to avoid misunderstandings, opengl es works only with triangles.
I got a rectangle (triangle strip), is it possible to cut a round hole (or more holes) into that rectangle. It's all in 2d.
At first, to avoid misunderstandings, opengl es works only with triangles.
I got a rectangle (triangle strip), is it possible to cut a round hole (or more holes) into that rectangle. It's all in 2d.
Nothing like real geometry subtraction is supported by opengl, but it can be pretty easily faked with either depth buffer or stencil buffer.
glColorMask(false, false, false, false)
Draw your 'hole' onto the scene, depositing values into either depth buffer (with value less than triangle strip) or stencil buffer.
Disable the color masks, and then render triangle strip with either depth or stencil test enabled. The area you drew earlier will be masked off, so you'll be left with a rectangle with a hole in the middle of it.
As an alternative to Tim's solution, you can also use a custom fragment shader that cuts the holes:
You can define your holes using a mask texture or just (x,y)-coordinates and radii. Then you can simply discard()
your triangle fragments if they are inside a hole.
The best solution might depend on the number of holes you want to have (a mask texture might be the easiest, most flexible approach, especially if you also want to have non-circular holes while the distance test might be good of you have only a few holes).