[SDL] Blitting speeds

John Garrison jeg at visi.net
Fri Aug 27 02:11:48 PDT 1999

> I tried playing around with the 'testsprite' program which comes with
> SDL. I get around 34 fps with 300 sprites and 280 fps with 3 sprites.
> There was not a hugh variation regardless of pixel depth or video flags
> or even DisplayFormat usage interestingly enough.

I converted one of my PowerPak examples to pure SDL so the users of this
group might be able to give me better advice.  Both the PowerPak and the
SDL versions get 26-27fps. The default setup for the testsprite.c gives
me about 150fps. I have to be doing something wrong. Hopefully you guys
can find it in the following code.

#include <time.h>

#include "SDL/SDL.h"

main(int argc, char *argv[])
   time_t time1, time2;
   int x;
   SDL_Surface *screen;
   SDL_Rect src;

   src.x = 0;
   src.y = 230;
   src.w = 10;
   src.h = 20;

   /* Initialize the library */

   /* Initialize 640x480x16bpp graphics mode */
   screen = SDL_SetVideoMode(640, 480, 16, SDL_HWPALETTE|SDL_DOUBLEBUF);

   /* Start timer */

   /* move the circle across the screen */
   for (x = 0; x < 640; x++){
        if ( SDL_MUSTLOCK(screen) )

      SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format,
      src.x = x;
      SDL_FillRect(screen, &src, SDL_MapRGB(screen->format,

     if ( SDL_MUSTLOCK(screen) )


   /* Stop Timer */

   fprintf(stderr,"fps = %d\n", 640/(time2-time1));

   /* Cleanup */

More information about the SDL mailing list