[SDL] slooow

Mattias.Blomqvist at nokia.com Mattias.Blomqvist at nokia.com
Thu Apr 6 07:09:55 PDT 2000


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();
                                                              



More information about the SDL mailing list