Polygon with a hole

I would like to draw a polygon over an environment and then I would be able to see the scene just through a hole in this polygon. For exemple:

                            ******************           ******************
| || || || |         +         ****                ****     =    ****| ||             ****
| || || || |                    **                       **           **| || || ||                 **
                            ****                ****            ****                ****
                            ******************           ******************
scene                  cloudy polygon                  we just can see
                                 with a hole                    part of the scene

Any ideias about how to make hole in a polygon?

Arghh!!!

What happened to my ilustration??
It does not accept “spaces”!

  1. You can draw the poly completely by yourself, which means you are free to bould it up of triangles.

  2. You could use polygon tesselation (search for tesselation in the docu).

But if you know how the poly is shaped, build it up on your own as fixed code.

Kilam.

The polygon should be a QUAD and the hole a circunference.
Is there any way to subtract shapes? I mean, take a quad and subtract a circle… than the problem would be over.

If you want the subtraction, the hole in the polygon, to be static, then the best solution is, to build the whole thing including the hole, out of triangles.
If it’s supposed to be dynamic (the position of the hole in the quad changes), you have 2 possibilities:

  1. compute the geometry of the polygon with the hole at the current position for every frame
  2. use the stencil buffer (draw the circle into the stencil buffer, then draw the quad everywhere where the stencil buffer is empty)

Sounds like shooting holes… Maybe use a 1 alpha bit texture (ie: transparent of not)? That wouldn’t be very fast though (since you don’t know which faces are behind it and would have to draw all). Maybe add little portals… Okay, sounds slow as well.