Rabbyt is a fast 2d sprite library for Python.
init_display(size=(640, 480), flags = 0)
This is a small shortcut to create a pygame window, set the viewport, and set the opengl attributes need for rabbyt.
flags is passed to pygame.display.set_mode() (OR'ed with pygame.OPENGL and pygame.DOUBLEBUF.)
The pygame surface returned by pygame.display.set_mode() is returned.
This function depends on pygame.
set_viewport(viewport, [projection])
Sets how coordinates map to the screen.
viewport gives the screen coordinates that will be drawn to. It should be in either the form (width, height) or (left, top, right, bottom)
projection gives the sprite coordinates that will be mapped to the screen coordinates given by viewport. It too should be in one of the two forms accepted by viewport. If projection is not given, it will default to the width and height of viewport. If only the width and height are given, (0, 0) will be the center point.
set_default_attribs()
Sets a few of the OpenGL attributes that sprites expect.
Unless you know what you are doing, you should call this at least once before rendering any sprites. (It is called automatically in rabbyt.init_display())
set_gl_color(rgba)
This is a thin wrapper around glColor4f().
clear(rgba=(0.0,0.0,0.0,1.0))
Clear the screen to a background color.
gl_get_vendor()
Returns the OpenGL vendor string. Returns None if there is no context.
render_unsorted(sprites)
Renders a list of sprites.
Since this function is implemented in Pyrex, it should be a little faster than looping through the sprites in Python.
load_texture(byte_string, size, type='RGBA', filter=True, mipmap=True)
Load a texture and return it.
update_texture(texture_id, byte_string, size, type='RGBA', filter=True, mipmap=True)
Update a texture with a different byte_string.
unload_texture(texture_id)
Unload a texture from memory.
pygame_load_texture(filename, filter=True, mipmap=True) -> texture_id, size
Reads an image from a file and loads it as a texture. Pygame is used for reading the image.
If filename is a relative path, the working directory is searched first, then rabbyt.data_directory is searched for the file.
set_load_texture_file_hook(callback)
This sets the callback that is used to load a texture from a file. (It is called when you give a string for the first argument of Sprite.)
The default is rabbyt.pygame_load_texture, which will use pygame to load the file. You may write your own callback if you don't want to use pygame.
The callback should take the filename as a single argument, and return a tuple of the form (texture_id, (width, height)).