Skip to content

@adamlwgriffiths /fix_codecs.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fix Pyglet textures loading as greyscale in OS-X due to issues in the Quartz loader
import sys
import pyglet
# on OS-X 10.7 (lion)
# the Quartz codec is buggered in Pyglet
if sys.platform == 'darwin':
# clear the existing codecs
pyglet.image.codecs._decoders = []
pyglet.image.codecs._decoder_extensions = {}
pyglet.image.codecs._decoder_animation_extensions = {}
pyglet.image.codecs._encoders = []
pyglet.image.codecs._encoder_extensions = {}
# just fallback to PIL
try:
import pyglet.image.codecs.pil
pyglet.image.codecs.add_encoders(pyglet.image.codecs.pil)
pyglet.image.codecs.add_decoders(pyglet.image.codecs.pil)
except ImportError:
pass
# Compressed texture in DDS format
try:
from pyglet.image.codecs import dds
pyglet.image.codecs.add_encoders(dds)
pyglet.image.codecs.add_decoders(dds)
except ImportError:
pass
# Fallback: PNG loader (slow)
try:
import pyglet.image.codecs.png
pyglet.image.codecs.add_encoders(pyglet.image.codecs.png)
pyglet.image.codecs.add_decoders(pyglet.image.codecs.png)
except ImportError:
pass
# Fallback: BMP loader (slow)
try:
import pyglet.image.codecs.bmp
pyglet.image.codecs.add_encoders(pyglet.image.codecs.bmp)
pyglet.image.codecs.add_decoders(pyglet.image.codecs.bmp)
except ImportError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.