Setting A Non-Rectangular Clip Area In GLES

Member
Posts: 24
Joined: 2009.03
Post: #1
Hi,

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?

cheers
Quote this message in a reply
Member
Posts: 283
Joined: 2006.05
Post: #2
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.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 24
Joined: 2009.03
Post: #4
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!

cheers
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #5
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 24
Joined: 2009.03
Post: #6
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)!

Thanks again.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Texturing using gles 2 jeckil 4 5,778 Apr 20, 2010 03:42 PM
Last Post: jeckil
  iPhone GLES 2 Orthogonal frame jeckil 2 2,951 Apr 16, 2010 08:33 AM
Last Post: dazza
  Old style 8bit gfx with clip colour on Iphone ? Emme73 7 3,762 Dec 4, 2009 04:50 AM
Last Post: Emme73
  rectangular uncompressed textures captainfreedom 8 5,122 Oct 2, 2009 08:26 AM
Last Post: warmi
  restricting events to clipping area charshep 0 1,408 Aug 13, 2009 10:47 AM
Last Post: charshep