Reducing pygame cpu-load to < 4 %

Roberto Fagá robertofaga at gmail.com
Sun Dec 9 19:51:08 EST 2007


Just adding, to convert at load time with pygame, just need to use
.convert() on surface object, and it'll convert to the screen surface,
like

surf = load(..)
surf.convert()

I think for now pygame is doing with 16bits at default yet, and I
wrote wrong, the second parameter from set_mode are the flags, depth
is the third parameter. I also used 12bits too to test, for games when
colors don't matter so much can be a good choice.
Was 16bits the default depth since the first pygame for XO? I
remembered that it was creating 32bits for me by default, but with
older versions of Sugar...

[]'s

On Dec 9, 2007 10:29 PM, Bernardo Innocenti <bernie at codewiz.org> wrote:
> On 12/09/07 19:08, Noah Kantrowitz wrote:
> > Unfortunately this is not possible in most games, as doing them purely
> > vector-based is infeasible. A lot of the artwork made for games will be
> > standard raster graphics, and will need to be designed for a specific
> > screen. If there are changes in the future, they can always be redrawn.
>
> The conversion to the screen format can happen at load
> time, rather than each time the bitmap is being redrawn
> on screen.
>
> Doing it systematically is very easy:
>
>   Surface *load_image(const char *filename)
>   {
>       Surface *s = NULL, tmp;
>
>       if ((tmp = IMG_Load(filename))
>       {
>           s = SDL_DisplayFormat(tmp);
>           SDL_FreeSurface(tmp);
>       }
>       return s;
>   }
>
> Some libraries, notably SDL, make blitting graphics between
> different pixel formats a little bit too transparent.
> As a result, developers don't even notice and huge performance
> bugs like this slip through.
>
>
> --
>  \___/
>  |___|   Bernardo Innocenti - http://www.codewiz.org/
>   \___\  One Laptop Per Child - http://www.laptop.org/
>



More information about the Devel mailing list