I've been working on a 2d shadow system for a school project, using this method to generate visibility polygons. However, I'm having issues figuring out how to draw those visibility polygons in a way that reveals everything drawn within them, rather than drawing over them like a normal sprite would.
From what I've been able to figure out, it seems like what I want to do is to draw the visibility polygons to some texture first, and then use that texture somehow when drawing the rest of the objects on the screen to get the shadow/light effect.
Unfortunately all the tutorials I've been able to find aren't very helpful. So, my questions are:
1) How do I tell OpenGL to render to a texture instead of the screen?
2) How do I use that texture to create the effect I want?