Skip to content

Instantly share code, notes, and snippets.

@reidrac
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reidrac/9874610 to your computer and use it in GitHub Desktop.
Save reidrac/9874610 to your computer and use it in GitHub Desktop.
Use pyglet sprites, but with a scaling filter that suits pixelated graphics
"""
Class to use Pyglet 1.2 sprites, but with a scaling filter that suits pixelated graphics.
Just import and use PixSprite as it was a Sprite!
"""
import pyglet
from pyglet import gl
class PixSprite(pyglet.sprite.Sprite):
def __init__(self, *args, **kwargs):
super(PixSprite, self).__init__(*args, **kwargs)
gl.glTexParameteri(self._texture.target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glTexParameteri(self._texture.target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment