Hello all,
I am a newbie to SDL programming.
I am currently working on what is quickly becoming a SDL tetris game.
Now that I finally got the main game loop going I realise that I have a
problem… The problem I run into is that the main loop takes 45ms to
run thru each time. When I limited it down I found out that it is
SDL_Flip() that is eating up all of my time. I am currently trying for
1024x768 16bpp SDL_DOUBLEBUF, SDL_FULLSCREEN
Does anyone have any ideas why I would be getting such terrible
performance? It seems to me that by now, with advanced cards like my
GeForce that simple 2d graphic blitting should be very simple, quick and
smooth. I mean years ago people like Apogee were pumping out game after
game with smooth quick 2d graphics. Any ideas on what I may be doing
wrong? Is SDL up to the challenge of making a simple tetris game? 
Sorry if anyone is offended by that question. I’ve just been trying to
figure this out for a week now.
thanks
Jaren Peterson
First off, I am assuming that you have done some serious testing and found
that the issue truely is the SDL_Flip(). Here’s some VERY simple things
that may actually be the issue. Did you try compiling it as a release
version? Also, are you using the debug DLL or the release DLL (or .la if
Linux, or whatever)? Just doing that may speed it up as the compiler has
not yet optimized ANY code.
Another thing to thing about is that an SDL_Flip() on a 1024x768X16bpp
surface must move 1.5 MB of data MINIMUM… (It may actually be using 32 bpp
and changing it on the fly.) If you are using software surfaces, this may
take a while to propagate across the PCI or AGP port. Though, I agree that
it should be able to do it.
My recommendation is to try the release versions. If that doesn’t help, try
looking again, because the issue might not actually be the SDL_Flip().
Actually, last minute thought. Check if the hardware can support HW
accelerated blits between the surfaces you are talking about (func =
SDL_GetVideoInfo)
Joe Tennies> ----- Original Message -----
From: owner-sdl@lokigames.com [mailto:owner-sdl at lokigames.com]On Behalf
Of Jaren Peterson
Sent: Thursday, February 22, 2001 11:47 PM
To: sdl at lokigames.com
Subject: [SDL] Witts end!!
Hello all,
I am a newbie to SDL programming.
I am currently working on what is quickly becoming a SDL tetris game.
Now that I finally got the main game loop going I realise that I have a
problem… The problem I run into is that the main loop takes 45ms to
run thru each time. When I limited it down I found out that it is
SDL_Flip() that is eating up all of my time. I am currently trying for
1024x768 16bpp SDL_DOUBLEBUF, SDL_FULLSCREEN
Does anyone have any ideas why I would be getting such terrible
performance? It seems to me that by now, with advanced cards like my
GeForce that simple 2d graphic blitting should be very simple, quick and
smooth. I mean years ago people like Apogee were pumping out game after
game with smooth quick 2d graphics. Any ideas on what I may be doing
wrong? Is SDL up to the challenge of making a simple tetris game? 
Sorry if anyone is offended by that question. I’ve just been trying to
figure this out for a week now.
thanks
Jaren Peterson
Jaren Peterson wrote:
Hello all,
I am a newbie to SDL programming.
I am currently working on what is quickly becoming a SDL tetris game.
Now that I finally got the main game loop going I realise that I have a
problem… The problem I run into is that the main loop takes 45ms to
run thru each time. When I limited it down I found out that it is
SDL_Flip() that is eating up all of my time. I am currently trying for
1024x768 16bpp SDL_DOUBLEBUF, SDL_FULLSCREEN
Does anyone have any ideas why I would be getting such terrible
performance? It seems to me that by now, with advanced cards like my
GeForce that simple 2d graphic blitting should be very simple, quick and
smooth. I mean years ago people like Apogee were pumping out game after
game with smooth quick 2d graphics. Any ideas on what I may be doing
wrong? Is SDL up to the challenge of making a simple tetris game? 
Sorry if anyone is offended by that question. I’ve just been trying to
figure this out for a week now.
thanks
Jaren Peterson
45ms? That’s 22fps, which is pretty reasonable for 1024x768 hicolor. Not
excellent, but believable.
If you’re on a system that doesn’t do page flipping (which is probably
the case if you’re using plain X11), SDL has to copy the entire video
surface for each update, which is a very time consuming operation.
Which OS/windowing system are you using? If it’s X11, what color depth
is your X server running at?
A few tips for speeding up high-res animation under inept graphics
systems like X:
-Make sure your app uses the same color depth as the desktop, or SDL
will have to do on the fly conversion. Slow.
-If at all possible, use partial screen updates (SDL_UpdateRect as
opposed to SDL_Flip).
-Make liberal use of SDL_DisplayFormat.
-Run as root under XFree86 4.0 to get DGA2 support.
-John–
Underfull \account (badness 10000) has occurred while \spend is active
John R. Hall - Student, Georgia Tech - Contractor, Loki Software
as always good advice John, just a clarification:
-If at all possible, use partial screen updates (SDL_UpdateRect as
opposed to SDL_Flip).
SDL_UpdateRects() is the prefered call for software screen surfaces,
more efficient than SDL_UpdateRect() for multiple updates