Hi,
We’re making a game with SDL, currently only for Windows. It’s a
puzzle/action game, 2D, with some sprites constantly moving on-screen
(on a 500x500 pixels area, screen res: 800x600).
We need to use Alpha blitting to show smooth sprites over the
background, but we found it too slow.
Basically we’re doing something like:
screen = SDLSurface (tried HWSURFACE, SWSURFACE, double and single
buffer, results are almost the same)
backbuffer = SDLSurface (SWSURFACE, also tried HWSURFACE and making all
our images HW also)
- blit the background to backbuffer
- blit all interface elements and sprites to the backbuffer (the
game is mostly buttons and a big area with some characters running all
the time) - blit backbuffer to screen
- SDL_Flip() - voila!
We record the time with something like this:
lastCalled = GetTickCount();
Repaint();
pThis.logFile << "Repaint Time: " << ( GetTickCount() -
lastCalled ) << endl;
And we obtain something like this (milliseconds):
…
Repaint Time: 47
Repaint Time: 46
Repaint Time: 47
Repaint Time: 32
Repaint Time: 46
Repaint Time: 47
Repaint Time: 47
Repaint Time: 47
Repaint Time: 47
Repaint Time: 47
…
Which means that we might get between 20 and 30 FPS, although most of
the time it seems near 20 (and sometimes time is 60+ ms!)
Our machines are Athlon 1700+/384MB RAM/GForce2MX400 & Athlon
2000+/512MB RAM/GForce4MX440. Maybe not next-gen, but sure not slow.
Some extra info:
- Game state is mantained using an SDL_Timer @ aprox. 20 ms interval.
The timer function updates the game with the “real” time elapsed
(according to GetTimerCount()). - Repaint snippet posted above resides in another SDL_Timer,
somewhere else in the program. - Interface events are catched in a loop like:
while( !exitApp ) {
SDL_WaitEvent(&sdlEvent);
ProcMessage( sdlEvent );
}
In the “main” thread of the program.
So, the question is: ?Are this results the best we might get (20 fps
@ 800x600), or are we doing something really really wrong? I looked for
but could not find benchmark results of alpha blitting with SDL. I’ll
try to make some, but any info will be greatly appreciated.
Thanks a lot… and sorry for the lengthly mail!–
///
Sebasti?n Uribe
Inmune Games
suribe at inmune.com.ar
www.inmune.com.ar