Original Post
I did a short test; I filled the screen with tiled bitmaps and then moved a second bitmap over that background. I initialized with SDL_HWSURFACE | SDL_DOUBLEBUF and used SDL_Flip to update after each redraw.
On a 2.5Ghz PC with a built-in gfx card I got 120fps and a smoothly moving bitmap. On my gaming PC at 2.0Ghz and a GeForce 3-card I only got 35fps and the movement of the moving bitmap was far from smooth.
Can anyone help me understand why? My only guess is that somehow the graphics acceleration doesn't kick in (but shouldn't I get errors on the HWSURFACE-initialization then?).
A second question: the decrease in performance is quite big between different bit-depths (like 35fps in 32bpp and 70fps in 16bpp), should it really? At 640x480 on a 2Ghz machine?!
A third, related question, the documentation at libsdl.org is pretty old, is there anywhere else one might find a more recent documentation? I hear they have a wiki, but I can't find a link to it.
The ugly, procedural, test code (just cut-paste-and-compile if you have SDL installed (don't forget to change code generation to multi-threaded dll)) in case anyone wants to try it out.
The test.bmp is 120x120...
/* -- Include the precompiled libraries -- */
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif
#include <stdio.h>
#include "SDL.h"
// Global variables
SDL_Surface *screen;
// main()
int main(int argc, char **argv)
{
SDL_Surface *myimage;
SDL_Rect *mydest;
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
SDL_Quit( );
}
screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
if ( screen == NULL ) {
fprintf(stderr, "Couldn't set 640x480x16 video mode: %s\n",
SDL_GetError());
SDL_Quit( );
}
myimage = SDL_LoadBMP("test.bmp");
int x,y,count;
mydest->h = 120;
mydest->w = 120;
for(count=0;count<100;count++)
{
for(y=0;y<4;y++)
{
mydest->y = 120*y;
for(x=0;x<6;x++)
{
mydest->x = 120*x;
SDL_BlitSurface(myimage, NULL, screen, mydest);
}
}
mydest->x = count*5;
mydest->y = count*5;
SDL_BlitSurface(myimage, NULL, screen, mydest);
SDL_Flip(screen);
}
printf("Active for %.2f seconds at %.2f fps.\n", ((float) SDL_GetTicks()/1000), (100/((float) SDL_GetTicks()/1000)));
SDL_Quit( );
return 0;
}
// end main()
[edited by - Xipe on June 3, 2004 3:20:34 PM]