On 9/24/08, Ragzouken <[EMAIL PROTECTED]> wrote:
>
>  I have a group for pixel graphics which should have alpha transparency
>  but should be scaled with nearest neighbour so they don't blur. In my
>  program a single instance of this group with a single child, an
>  instance of a transformation group (uses rotate/translate/scale etc)
>  which has several children OrderedGroup and each of those children has
>  a child TextureGroup of a particular texture.
>
>  The PixelGraphicGroup used to be used as the child of the TextureGroup
>  and worked fine. Because it's the same state for all the graphics in
>  the group I decided to move it to be the root of the tree. Now it
>  doesn't work. Commenting out blend enabling has the expected effect,
>  but the mag/min filters don't appear to affect it anymore. What am I
>  doing wrong?
>
>  class PixelGraphicGroup(Group):
>         def set_state(self):
>                 gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT | gl.GL_TEXTURE_BIT)
>                 gl.glEnable(gl.GL_BLEND)
>                 gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
>                 gl.glTexParameterf(gl.GL_TEXTURE_2D,
>                                                         
> gl.GL_TEXTURE_MAG_FILTER,
>                                                         gl.GL_NEAREST)
>                 gl.glTexParameterf(gl.GL_TEXTURE_2D,
>                                                         
> gl.GL_TEXTURE_MIN_FILTER,
>                                                         gl.GL_NEAREST)
>
>         def unset_state(self):
>                 gl.glPopAttrib()

As I understand it, texture parameters are properties of the texture,
not part of the context state.  So it's necessary to bind the texture
before setting its parameters.  Luckily for you, this means you can
actually remove the parameter settings from the group entirely, and
set them once per texture after loading only.

One potential problem you may encounter is if using
pyglet.resource.image, the images may be packed into textures
alongside other images that you do not want these properties set on
(in which case you should use TextureAtlas explicitly to manage your
texture loading).

Alex.

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