Advertisement

Is SDL too slow?

Started by January 09, 2005 03:54 PM
8 comments, last by benryves 19 years, 8 months ago
I've started working on a simple 2d game engine. I've written a demo that draws tiles, moves a sprite around (time based, with the arrow keys) and plays a sound when the mouse is clicked. My system is a P4 2.8ghz with a 160 gb hdd and a crappy integrated intel extreme graphics card. Here is the beginning of my fps log: FPS: 250 FPS: 166.667 FPS: 111.111 FPS: 71.4286 FPS: 76.9231 FPS: 76.9231 FPS: 76.9231 FPS: 71.4286 FPS: 76.9231 My questions is why does it start high and then lower down and level off. I removed all of the drawing code and got no increase in FPS. What does this mean? Am I passing the wrong params to setvideomode or something?
case ShmuelPosted:StupidPosts++;
I do not think SDL is too slow for basic 2d needs. However -
Quote: crappy integrated intel extreme graphics card

could be one reason. Also, how are you retrieving the FPS?

[edit] When I run an empty SDL window, I am averaing around 335fps and I have a
Powercolor Ati Radeon 9600 Pro 128mb ram 8x agp. I think I would suggest using 2D OpenGL instead if you are worried that the fps may be too low - you can even take a look at this post if you need an easy way to do it (PnP I'd better be getting a commission [lol]).

I guess I will hav to say that maybe SDL is to slow now...everything seems to be moving to using 3D for 3D as well as 2D (no more 2D DirectDraw even).
Advertisement
Are you using SDL_SWSURFACE or SDL_HWSURFACES w/ Double Buffering? I did some tests, and I found that on my machine (1.4 Ghz Pentium M w/ Intel Integrated Graphics card), that software surfaces were faster. Also, if you are using Software Surfaces, then the graphics card should make little difference as all the blitting will be done by the CPU (I also tested my results against a machine w/ a 128MB NVidia card and similar processor speed and we both had similar fps).
What I've heard about SDL is that it uses an old version of DirectDraw that most cards today don't support acceleration for. Someone that tested my sample had an FPS of 5 with an ATI card that pwns my card. Anyway, here is how I get the FPS:

// right before game logic:timerdiff = SDL_GetTicks() - timer;// get new timetimer = SDL_GetTicks();// game logic// draw scenelogfile << "FPS: " << float(1000 / timerdiff) << std::endl;
case ShmuelPosted:StupidPosts++;
The fact that it's locked at a very specific number (76.blah) Suggests that it's not hte library being slow, but something like a vsync lock on framerate.

and intel's graphics architecture is not slow for anything but complicated 3d.

I can play counterstrike on my IEG2 laptop. (i855GM chip, which is one of the lower end IEG2 chips, I believe) It'd certainly work for 2D.

There are things to think about when optimizing SDL, though. Ever used DisplayFormat?
Meh, any video hardware post 1996 is going to run the same when just using SDL's 2d stuff.

Try forcing software when you create your video context. You may actualy get an FPS boost. That changes the upper limmit from your video card to your main processor.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Advertisement
Quote: Original post by wyrzy
Are you using SDL_SWSURFACE or SDL_HWSURFACES w/ Double Buffering?


I am using SDL_HWSURFACE w/double buffering. I changed it to SDL_SWSURFACE, but did not get an increase or decrease in FPS.
case ShmuelPosted:StupidPosts++;
Quote: Original post by Shmuel
Quote: Original post by wyrzy
Are you using SDL_SWSURFACE or SDL_HWSURFACES w/ Double Buffering?


I am using SDL_HWSURFACE w/double buffering. I changed it to SDL_SWSURFACE, but did not get an increase or decrease in FPS.


How are you clearing and updating the screen? That would have a big impact on the FPS as well.
Hardware surfaces and hardware acceleration are pretty much only supported in fullscreen mode for plain old SDL which is where you see major speed differences in the library you choose (SDL vs SDL w/OpenGL). This may be a problem for most newer cards out there with really crappy 2d support. If the speed is really an issue then SDL w/OpenGL is the way to go. Personally I am finding that using plain old SDL and making it work at a decent speed is both educational and gratifying. Besides, I don't really need blending, rotation or stretching much which are the real bottlenecks with any 2d API (although I believe ddraw7 has hardware stretch) since they are emulated in software. On the funny side, my old voodoo3 card is actually faster with regular SDL than OpenGL, go figure.
Evillive2
I get an enourmous boost in FPS by creating all my surfaces in software - then again, I am working entirely in software anyway, and it's faster to play with individual pixels in a surface if it's in system memory rather than on the graphics card. When I say "enourmous", I mean my raycaster jumped from ~20 to ~50 FPS. Then I optimised it then added floors, and I'm back to 20. Bah [sad]

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

This topic is closed to new replies.

Advertisement