1

I want to mask an arbitrary convex polygon area of an image and put another image into that area. I found this posting, but is wasn't clear to me if this applies only to rectangular areas and not arbitrary polygons.

The basic flow I am talking about is to have an (x,y) coordinate on the screen which would serve to be the center of my polygon (center in terms of an arbitrary point which is consistent for me). I would like to mask this area where the new image (polygonal in nature) would be displayed while leaving the rest of the screen as is.

Can I do this easily and quickly?

Community
  • 1
  • 1
No One in Particular
  • 2,846
  • 4
  • 27
  • 32

2 Answers2

0

You have to use stencil buffer. It's basically another type of buffer that has plethora of awesome applications and one of the simplest one is masking. While I can't recommend any OpenGL ES specific tutorial off the top of my head, I highly recommend reading general tutorials, since it's not that different and surely is fascinating.

Bartosz Ciechanowski
  • 10,293
  • 5
  • 45
  • 60
-1

Try glScissor... it might be the rectangle you want.

starmole
  • 4,974
  • 1
  • 28
  • 48
  • glScissor seems to only work on rectangles (if I read teh documentation correctly). Is this true? I want an arbitrary polygon, not just a rectangle. – No One in Particular Apr 11 '11 at 10:38
  • wow, long time ago :) but yes, my answer was way of. The right thing would be around stencil buffers. Doesn't seem worth the effort now though, looks like the question was abandoned a long time ago also. – starmole Nov 17 '12 at 10:51