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.

You should follow us on Identi.ca or Twitter


Your comments

py2exe

Has anyone succesfully created an exe using py2exe ?

I keep getting

...\gloss0.6\examples\dist\example_particles.exe\gloss.py:76: RuntimeWarning: use mixer: MemoryLoadLibrary failed loading pygame\mixer.pyd
Traceback (most recent call last):
File "example_particles.py", line 58, in <module>
File "gloss.pyo", line 159, in run
File "gloss.pyo", line 76, in gloss_initialise
File "pygame\__init__.pyo", line 70, in __getattr__
NotImplementedError: mixer module not available

So anyone who is using

So anyone who is using Pygame under the LGPL and wants to use your code must now infect their code with the GPLv3? Pfffffft.

Seems like the less dickish thing to do would be to release it under the same license as Pygame, but whatever, it's your code.

I'm glad it's GPLv3

I, for one, welcome the GPLv3 licencing. The GPL version three has been out for some time, and people are simply ignoring it. Let's not forget GPLv3 is the only software licence that protects us from the danger of patents and that makes software stay free, as well as being the licence corporations dislike and are afraid of.

Just kindly release your software under the GPLv3, or kindly shut up and use something else; I suggest msdn.com for you.

Any ideas?

Is this a gloss issue, or a problem with something else I'm doing? On one of my machines everything works beautifully, but on the other machine...

Traceback (most recent call last):
File "example_loadingscreen.py", line 23, in <module>
game.run()
File "/home/username/tmp/gloss0.7/examples/gloss.py", line 159, in run
self.gloss_initialise()
File "/home/username/tmp/gloss0.7/examples/gloss.py", line 98, in gloss_initialise
Gloss.MaxTextureSize = glGetInteger(GL_MAX_TEXTURE_SIZE);
File "/usr/lib/python2.6/dist-packages/OpenGL/wrapper.py", line 1631, in __call__
return self.finalise()( *args, **named )
File "/usr/lib/python2.6/dist-packages/OpenGL/wrapper.py", line 683, in wrapperCall
converter( pyArgs, index, self )
File "/usr/lib/python2.6/dist-packages/OpenGL/converters.py", line 195, in __call__
return self.arrayType.zeros( self.getSize(pyArgs) )
File "/usr/lib/python2.6/dist-packages/OpenGL/arrays/arraydatatype.py", line 98, in zeros
return cls.returnHandler().zeros( dims, typeCode or cls.typeConstant )
File "/usr/lib/python2.6/dist-packages/OpenGL/arrays/nones.py", line 32, in zeros
raise TypeError( """Can't create NULL pointer filled with values""" )
TypeError: ("Can't create NULL pointer filled with values", 'Failure in cConverter <OpenGL.converters.SizedOutput object at 0xa16379c>', [GL_MAX_TEXTURE_SIZE], 1, <OpenGL.wrapper.glGetIntegerv object at 0xa18e7ec>)

download problem

Hi,

I've tried to download it several times but each time I was unable to unpack it with tar xzf. It says it does not look like a tar archive.
Can I download it from elsewhere?

download problem SOLVED

sorry, was my fault. I've tried it with a separate gunzip and untar and it worked.

congratulations it is a quite good pygame extension, I am amazed.

**thumbs_up**

30FPS?

For some reason, even a simple game is running at only 30 FPS. Not around 30 FPS, *exactly* 20 FPS. This makes me thing the bug is quite possibly pretty insidious. Anyone having this problem?

Problem with Ubuntu 10.04

Why doesnt it work on ubuntu 10.04??
I really whant to try it but y cant run it 'cose it just doesnt do a thing, the program stops when Gloss is supose to start D=
Please, help me.

gloss doesnt show nothing

Hello. gloss (0.9) seems doesn't show nothing. Python runs but it's frozen.
Im using GNU/Linux lenny, python 2.5.

I'm also having problems

I'm also having problems trying to run example files on Ubuntu 10.04.

Any fix?

Fixing Click Detection

Just wanted to point out, the example_onclick.py will crash because Gloss doesn't dereference the weakref before it tries to use it. To fix this look at line 738 in gloss.py; It's currently:

for sprite in Gloss.sprites:

Change it to:

for tempSprite in Gloss.sprites:
sprite = tempSprite()

Fixed! Thanks for the library!

Thanks a lot !!!

This is exactly what I was looking for, great !

BTW, is the library still being developed ?

Cheers !

Colission detection

Gloss doesn't have it own collision detection >.>
I've been trying to use pygames but that requires you to make a pygame background while drawing with gloss not pygame just to have accurate collision detection. Spherical collision containers are out of the question.

комментарий к теме

Автомобили : Прокат авто в киеве

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

CAPTCHA
We can't accept links (unless you obfuscate them). You also need to negotiate the following CAPTCHA...

Username:   Password:
Create Account | About TuxRadar