You will need to subclass pyglet.sprite.Sprite and override the following
method:
def set_state(self):
glEnable(self.texture.target)
glBindTexture(self.texture.target, self.texture.id)
glPushAttrib(GL_COLOR_BUFFER_BIT)
glEnable(GL_BLEND)
glTexParameteri(self.texture.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glBlendFunc(self.blend_src, self.blend_dest)
The reason this works is due to the way pyglet handles the OpenGL state
machine. When a sprite is going to get drawn, pyglet will execute the
OpenGL commands inside Sprite.set_state so that the texture is rendered as
intended. There really isn't an easier way. I've tested this, and on my
computer, it works fine, even with fractional scale values on the sprite.
On Thursday, January 1, 2015 at 5:54:46 AM UTC-6, Salvakiya wrote:
>
> I am relatively new to python and am creating a game engine called PyGM. I
> am trying to create Game Maker logic in Python. I chose Pyglet to handle
> the graphics on this project however I have run into a few issues.
>
> The first issue was I could not scale a sprite without it becoming blurry
> due to the biliniar texture filtering. After some research I found a fix by
> using this code:
>
> def texture_set_mag_filter_nearest(texture):
> glBindTexture(texture.target, texture.id)
> glTexParameteri(texture.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
> glBindTexture(texture.target, 0)
>
> there is however another issue. The sprites look fine when scaled to a
> whole number but when scaling to anything else(like 2.5) produces strange
> results.
>
> Is there a way to fix this?
>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.