On Tue, Feb 16, 2010 at 9:55 AM, Philippe <[email protected]> wrote:

> Hi,
>
> One more beginer question...
> I have some sprites, in a Class. I can move this group of sprites,
> scale them, ...
>
> What is the best way to apply a mask on that group ?
> For me, a Mask is a description of what will be displayed from that
> group of sprites.
> The best would be a mask of any shape, but a rectangular mask would be
> great already.
>
> I did not find things in Pyglet to do that directly.
>
> I hope someone can give me a nice advice on that.
>
> Philippe


For a simple rectangular mask, you can abuse the OpenGL scissor test (
http://www.khronos.org/opengles/documentation/opengles1_0/html/glScissor.html
).

For more complex masks, you can use several approaches (in rough order of
complexity):
a) render the mask to the stencil buffer, and then enable the stencil test
to discard pixels outside the mask.
b) use multiplicative blending and multi-texturing to erase the black
portion of the mask.
c) use a shader with the discard keyword to handle complex masking logic.

-- 
Tristam MacDonald
http://swiftcoder.wordpress.com/

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to