Gloss: a Pygame OpenGL wrapper
Gloss is a high-performance graphics wrapper around Pygame that lets you take advantage of OpenGL without having to delve into the murky depths of 3D programming. Gloss lets you build 2D games where you can rotate, scale and recolor sprites on the fly, and also includes a selection of helpful mathematics functions to make the life of games coders easier.
Gloss is licensed under LGPLv3, and comes with full documentation, a tutorial and several code examples to help get you started, so if you're looking to make a game quickly and easily give it a try!
Frequently asked questions
OpenGL is much harder than Pygame. Why should I use this?
Gloss uses OpenGL, but hides it all. Every last bit! All you need to do is make sure you have python-opengl installed (and perhaps also python-numpy depending on your Linux distro). OpenGL is indeed much harder than plain old Pygame, but the magic of Gloss is that to developers it looks like any other 2D drawing toolkit, but behind the scenes their calls get mapped into 3D for extra speed. That's why it can rotate and scale on the fly.
What does Gloss include?
The functionality most people will want to use in Gloss includes:
- Loading textures, then drawing them to the screen scaled, rotated, translucent and recolored
- Drawing text to the screen (yes, still with scaling, rotation, etc)
- Particle systems for common special effects such as fire and smoke
- Rendering scenes to a texture ("render targets") for complex effects
- Built-in support for lerping, normalization and scene tinting
- Easy API calls for anti-aliasing, screenshots, picking and more
Download the tarball and run some of the examples to see what Gloss can do.
Doesn't Pyglet do all this already?
Pyglet is a very cool and very mature OpenGL library for Python, but it serves quite a different purpose to Gloss. Gloss is designed to hide all the OpenGL calls behind simple wrappers so that it takes only a few minutes to learn, and you can do more just by experimenting. What's more, Gloss is designed to build on top of Pygame, which means you can use all your existing Pygame code for audio and other core functionality.
Is Gloss hard to learn?
Quite the opposite! Gloss has been designed to be a cinch to pick up - if you've made a game with Pygame before, you should be able to start using Gloss in under five minutes.
Do I just import Pygame like usual?
Yep, but please make sure you import it before you import Gloss, like this:
import pygame from pygame.locals import * from gloss import *
When I scale and rotate with Gloss, does it degrade my image over time?
No - you can scale and rotate your image as many times as you want, and not a single pixel of data will be lost. It's super fast and takes no CPU power, because it's all done on the GPU.
Do I have to use your Sprite class?
No - in fact most advanced coders will probably want to create their own sprite class specific to their needs. The built-in Gloss Sprite class is really just there to make things easier for beginners, as it automatically handles things such as click detection.
Hey - it crashed! Why are you making this thing suck?
Many Linux distros need the Python "Numpy" package installed in order to work, which is a bit annoying. If you have that installed and Gloss is still crashing, you've found a legitimate bug and should email me.
How do I get started making games?
When you download Gloss you'll find it comes with a tutorial, documentation and several examples to help get you started.
How can I contribute fixes or suggestions?
Email me your code/suggestion/feedback/hate mail and we'll talk.