[SDL] Code that produces low framerates

Marc Essinger codezilla at t-online.de
Mon Nov 25 03:02:02 PST 2002


Hello again,
so here is the init routine:

    
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO ) 
         < 0 )
    {
        return;
    }
      
    back_buff = SDL_SetVideoMode( 800, 600, 16, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL );
    if ( back_buff )  {
      set_rectangle( screen_rect, 0, 0, 800, 600 );
      SDL_ShowCursor( SDL_DISABLE );
      return;
   }

The bitmap surfaces are loaded via LoadBitmap and converted to screen format using SDL_DisplayFormat.

My blit looks like this:
SDL_BlitSurface( background, NULL, back_buff, NULL );
SDL_BlitSurface( fruits[ball->type()], NULL, back_buff, &ball->r );
SDL_BlitSurface( paddels[0], NULL, back_buff, &player1->r );
SDL_BlitSurface( paddels[0], NULL, back_buff, &player2->r );

I could improve the framerate by using SDL_DisplayFormat, but 60 fps aren't too much for a simple game like pong. My vertical refresh rate is 85 Hz, so it should produce at least 25 frames more. 

Thank you,
Marc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021125/5b3a045b/attachment.htm>


More information about the SDL mailing list