Setting A Non-Rectangular Clip Area In GLES - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Setting A Non-Rectangular Clip Area In GLES (/thread-673.html)
Setting A Non-Rectangular Clip Area In GLES - muleskinner - Oct 15, 2009 03:58 AM
I'm currently using glscissor() to clip the viewing area before drawing a section of an image to screen.
What I'd like to do a rotate the section of image I'm drawing. Is there any way to use glscissor (or something similar) to crop to arbitrary shapes like polygons or a rotated rect?
Setting A Non-Rectangular Clip Area In GLES - maximile - Oct 15, 2009 06:29 AM
If you're really just drawing an image, make a texture from it and bind it and draw any shape you like using geometry.
If you're drawing a scene rather than just an image, you can draw it to an FBO, bind its texture target and draw that as above.
Setting A Non-Rectangular Clip Area In GLES - Skorche - Oct 15, 2009 07:56 AM
You can use multitexturing if you have an image of the mask or use the target alpha and a blending function if you just want to draw polys to cut out the mask.
Setting A Non-Rectangular Clip Area In GLES - muleskinner - Oct 19, 2009 08:46 AM
OK, thanks for the replies.
Please bear in mind I am a complete GL noob.
To clarify - what I want to render to screen is actually a portion of a texture rather than an entire texture. I have rotation working fine when rendering a whole texture.
Any more pointers (in as simple terms as possible) appreciated!
Setting A Non-Rectangular Clip Area In GLES - Skorche - Oct 19, 2009 02:27 PM
How do you want to define the area that you want to clip? If you have a black and white image in the shape of the desired mask, you can use multitexturing to apply it. If you just wanted a rectangular (but rotated and not screen aligned) area, you could just draw some polygons to define the clipping mask in the framebuffer's alpha channel.
Multitexturing is fast and costs very little performance wise, but has to be applied to each drawn object individually. Using the destination alpha is simple and would work well for full screen transitions, but would be very expensive to use on a lot of individual objects.
edit: Adding on to what Maximile, if all you wanted was a cropped and rotated section of a texture that is even easier. Every textured triangle that you draw is basically a cropped triangle chunk taken out of the texture.
Setting A Non-Rectangular Clip Area In GLES - muleskinner - Oct 20, 2009 01:03 AM
OK, thanks guys. Your replies are still a bit over my head tbh but I think there's enough there for me to dive in and start getting my hands dirty (or should I say, dirtier)!