[SDL] Code that produces low framerates

Robert Diel robert at littlebitlost.com
Mon Nov 25 03:45:01 PST 2002


Let me ask the most basic question first, you are using SDL_flip and not
SDL_UpdateRect after you've updated back_buf?  You aren't using a frame
limiter of any sort are you like WaitFrame?  What video card are you
currently using?  I ask these questions only because I can't see
anything obviously wrong with the code you've listed.

gotta sleep,
Robert


On Mon, 2002-11-25 at 05:01, Marc Essinger wrote:
> 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






More information about the SDL mailing list