[SDL] Re: slooow

David R. Hayes theraven at eris.cc
Thu Apr 6 08:35:51 PDT 2000


Mattias.Blomqvist at nokia.com wrote:

> I've made a small program that blits a 720x576 (24 bpp) image into a 800x600
> SDL window. The problem is that its painfully slow. It takes over 200 ms to
> blit one image. Much much slower than doing it with gdk_draw_rgb_image (~110
> ms) from gtk+. Is it supposed to be like this? I'm looking for a way to do
> it alot faster. This is for a realtime video application and it requires
> much much faster video than this. The code can be found below. Ohh, the
> system is a pretty ordinary pentium2 running at 400 MHz. Video card is a ATI
> 3D Rage Pro. X-server is XFree86 3.3.6 and current depth is 24 bpp.
>
> Thanks in advance
> Mattias Blomqvist
>
>   if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
>         return -1;
>   }
>
>   screen = SDL_SetVideoMode(800, 600, 24, SDL_SWSURFACE);
>   if ( screen == NULL ) {
>     ComplainAndExit();
>   }
>   fread(ind,1,120000+PAL*24000,f);
>   screen2 = SDL_CreateRGBSurface(SDL_HWSURFACE, FRAME_WIDTH, FRAME_HEIGHT,
> 24, 0xff, 0xff00, 0xff0000,0);
>   dstrect.x = (screen->w-screen2->w)/2;
>   dstrect.y = (screen->h-screen2->h)/2;
>   dstrect.w = screen2->w;
>   dstrect.h = screen2->h;
>   screen2->pixels = frame;
>
>   while (!done && (getnextframe(frame) != 0)) {
>     if ( SDL_BlitSurface(screen2, NULL, screen, &dstrect) < 0 ) {
>       SDL_FreeSurface(screen2);
>         return -1;
>     }
>     SDL_UpdateRects(screen, 1, &dstrect);
>     while ( SDL_PollEvent(&event) ) {
>       switch (event.type) {
>       case SDL_KEYDOWN:
>         if ( event.key.keysym.sym == SDLK_ESCAPE ) {
>           done = 1;
>         }
>         break;
>       case SDL_QUIT:
>         done = 1;
>         break;
>       default:
>         break;
>       }
>     }
>   }
>   SDL_Quit();
>

I don't know too much about SDL, but I do know that 24 bpp modes tend to be
slower than 16 or 32... You could try switching it and see what it does... (=

        David




More information about the SDL mailing list