If you have a set of sprites that all need a particular mask, then in
general those sprites should belong to a pyglet group that sets up the
mask. Using a scissor mask seems easiest for rectangular masking, for
other shapes you could use the stencil buffer or multi texturing.

I did a quick grep of the pyglet source and I don't see an existing
scissor group implementation, so you'll need to make one. Basically
you just need to subclass pyglet.graphics.Group and implement the
set_state() and unset_state() methods to setup and teardown the
desired scissor rectangle. The rectangle could just be stored as some
custom attributes on your group class (maybe left, top, width,
height?).

-Casey

On Tue, Feb 23, 2010 at 12:33 PM, Philippe <[email protected]> wrote:
> hum, sorry for the double post.
>
> On 23 fév, 18:45, Philippe <[email protected]> wrote:
>> oh, seems like my last post did not work :/
>>
>> for me, a mask is that:http://www.entheosweb.com/Flash/masking.asp
>> in this sample, the mask is a moving circle. the sprite is the photo.
>> a mask can be of any shape, and applied to any number of sprites, it
>> is invisible, but hides sprites is specify.
>>
>> to describe little bit more my actuall need:
>> I have 5 group of 10 sprites. a group is a set of sprites, not a
>> pyglet.graphics.OrderedGroup(). each group has a different batch.
>>
>> I need to apply rectangular masks on them (on mask per group).
>> the sprites are moving, the mask keep fix.
>>
>> I hope it's easier to understand my question.
>>
>> Philippe
>>
>> On Feb 23, 6:20 pm, Casey Duncan <[email protected]> wrote:
>>
>> > What exactly are you trying to do? I'm skeptical that scissoring each
>> > sprite independently is really what you want, not that it isn't
>> > possible. Perhaps if we understood what you are doing better in the
>> > abstract we could formulate a good solution.
>>
>> > -Casey
>>
>> > On Tue, Feb 23, 2010 at 9:59 AM, Philippe <[email protected]> wrote:
>> > > Hi,
>>
>> > > I searched a lot how to do something with your recommandations:
>> > > """As long as you render each group separately, yes.
>>
>> > > In pyglet, the best way to implement this would probably be a
>> > > 'ScissorGroup'
>> > > (much like OrderedGoup), which handles setting and unsetting the
>> > > scissor
>> > > rectangle. if I recall correctly, there might already be a
>> > > ScissorGroup
>> > > hidden away somewhere in the text rendering implementation... """
>>
>> > > but could not find.
>> > > I'm afraid I do not look in the right direction.
>> > > first, I am not sure to understand "As long as you render each group
>> > > separately, yes."
>> > > My group of sprites are in different batch. is it what you mean ?
>>
>> > > I know how to use Scissor to apply a mask on my total application
>> > > pyglet.gl.glScissor(offset_x, offset_y, 800, 480)
>> > > pyglet.gl.glEnable(pyglet.gl.GL_SCISSOR_TEST)
>>
>> > > But I do not see how to apply it to a single Sprite.
>> > > Can you give me a advice on that ?
>>
>> > > thank you
>>
>> > > On Feb 16, 5:21 pm, Tristam MacDonald <[email protected]> wrote:
>> > >> On Tue, Feb 16, 2010 at 10:36 AM, Philippe <[email protected]> 
>> > >> wrote:
>> > >> > it's possible to apply different scissor_test to different group of
>> > >> > sprites ?
>>
>> > >> As long as you render each group separately, yes.
>>
>> > >> In pyglet, the best way to implement this would probably be a 
>> > >> 'ScissorGroup'
>> > >> (much like OrderedGoup), which handles setting and unsetting the scissor
>> > >> rectangle. if I recall correctly, there might already be a ScissorGroup
>> > >> hidden away somewhere in the text rendering implementation...
>>
>> > >> --
>> > >> Tristam MacDonaldhttp://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 
>> > > athttp://groups.google.com/group/pyglet-users?hl=en.
>
> --
> 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.
>
>

-- 
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