Here’s a zipped up example program I’ve written.
All it does is loop around, blitting a blank screen over the top of the
current display.
In a window I’m getting about 12fps with a Windows 98 machine, a TNT 2 Ultra
and Direct X 7.
In full screen mode I’m getting about 20 fps.
This is terrible. What am I doing wrong?
Actually, that’s pretty good. I’m getting 9-10 FPS on my Matrox
Millennium II under X11 (P2-300)
24-bit mode is the slowest mode there is. I recommend running in 16-bit
mode for games, and 32-bit if you have special effects and so forth that
require the extra precision.
Right now, SDL is converting from 24-bit RGB to 16-bit RGB, and that’s
very expensive. If I change both surfaces from being 24-bit to 32-bit,
I get a jump to 21 FPS, even though SDL is still converting from 32 bpp
to my X server’s native 16 bpp. If I change both surfaces to 16-bit, i.e.
set a 16 bit video mode and create a 16 bpp surface, the framerate jumps
to 56 FPS. If I remove the blit and just perform a flip, then the
framerate jumps even higher to 103 FPS.
When using testsprite with 10 sprites on the screen, performing dirty
rectangle updates, I get an amazing 216 frames per second, just with X11
software rendering. When I use accelerated hardware the framerates jump
into the insane thousands of frames per second.
The moral of the story is: 24bpp is bad, m’kay?
BTW, I changed your event code so it actually responded to quit messages:
// Sam - this code never got triggered
//if( SDL_PollEvent(&event) == 0)
while ( SDL_PollEvent(&event) )
{
if( event.type == SDL_QUIT)
nQuit = true;
}
Enjoy!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software