Table of Contents

Module: spritegl rdpyg/sprites/spritegl.py

Opengl drawing of pygame.sprite objects. With hopefully minimal/no changes to programs, and big speed increases.

Rene Dudfield. illumen@yahoo.com

TODO:

First compatibilty, optimization, then next gen.

NOTE: there are some more TODO's sprinkled througout the code

Compatibilty. - need to implement all of screens methods.

  • test on more games. - chimp(works).

    • pyddr(doesn't work). - I think it has to do with the different format images. - I think a conversion may not be working properly.

    • bleten(works). - works, but is kinda slow when lots of images change. - need to work on a scaling method which uses opengl. - need to not use tostring() for making textures(slow). - work on caching some more, so that there is a texture cache as well. - so that images don't need to be uploaded to the card all the time.

    • yass(don't know).

  • a better way to detect when an images contents have changed. - probably a wrapper around surface, and surfarray which marks the image as dirty. - split sprites larger than 256x256 into multiple smaller textures. - for some older 3d cards. - should figure out how to detect max texture size.

  • support 8 and 16 bit and color keyed textures. - Make sure textures are cleaned up correctly in all cases. - Beta test on a wide number of machines.

  • Make it work correctly when the screen size changes.

Optimization.

  • Put multiple sprites onto the same texture, and use uv coords for drawing particular sprites. This is a big optimization. - especially for animation.

  • move all texture management into the group, so as to optimize texture drawing more easily.

  • Have a set max number of textures to use in a texture cache. - Cache textures

  • optimize the screen.blit function, and some others: - with blit, only update a certain part of the texture which was actually blitted. - screen.fill

  • Group drawing by the same texture(less texture binds). - Try display lists to see if better performing. - try vertex buffers for better performance. - Make 1000+ sprite test case, and optimize for this case. - Update texture instead of replacing it when: - some pixels change in an image. - when the image changes and the old one isn't to be used anymore. - How to know this?

Next gen. - Add scaling, rotation, other effects to a sprite class. - use caching of images for sdl, and straight opengl calls(eg glRotate etc). - shadows from sprites onto the background. - Make classes/optimize existing classes for drawing: - scrollers, tile maps, height maps, - 3d animated characters (http://www.py3d.org/py3d_zwiki/milkshape3d_animation) - doomIII clone ;)

Imported modules   
from OpenGL.GL import *
from OpenGL.GLU import *
import os
import pygame
from pygame.locals import *
from rdpyg.util import pack_textures
import time
Functions   
gl_display_get_surface
gl_display_set_mode
gl_display_update
gl_draw_line
gl_transform_scale
nextPower
printw
  gl_display_get_surface 
gl_display_get_surface ()

  gl_display_set_mode 
gl_display_set_mode ( *args )

TODO: Add check to see if a GL screen is infact being requested.

  gl_display_update 
gl_display_update ( *args )

  gl_draw_line 
gl_draw_line ( *args )

  gl_transform_scale 
gl_transform_scale ( *args,  *kwargs )

  nextPower 
nextPower ( x )

  printw 
printw ( *args )

Classes   

GroupGL

ScreenGL

TODO:

SpriteGL

A sprite class which uses opengl.

SurfaceGL

This is useful for tracking changes in a surface.


Table of Contents

This document was automatically generated on Sat Jul 30 12:45:41 2005 by HappyDoc version 2.1