Sign in to follow this  

SDL - hardware support and a file format

This topic is 4202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a couple of questions regarding SDL. 1. Can i somehow use hardware support for SDL? I'm asking because game i'm doing is running at extremely low framerates althought it is displaying only a few images. 2. Can i use another image files then .bmp for images in SDL? I would prefer some file formats that takes less place on hdd and in memory, like jpg for example.

Share this post


Link to post
Share on other sites
1) w/o OpenGL: Try creating your surfaces w/ SDL_CreateRGBSurface(SDL_HWSURFACE, ...), make sure the created surfaces are really hardware accelerated (check surface->flags for SDL_HWSURFACE) and finally keep them unlocked (that is: in VRAM) while blitting...

Share this post


Link to post
Share on other sites
In addition to what has been said:
- Other file formats like jpg will only take less space on HD, it will take the same amount of space in memory unless they are of different pixel format (8 or 16 bit instead of 32).

As for performance:
- Don't use alpha blending when having hardware surface's, use colorkey. If you need alpha blending, do everything in software or look into using opengl with sdl.
- Have all surfaces you blit in the same format as your display surface (a call to SDL_DisplayFormat will help).
- Make sure you ask SDL_SetVideoMode for a hardware display surface and got one, it's not guaranteed.
- Using a lower resolution can help.

If you do this and not anything crazy, you should be able to achieve a decent framerate. Try using a profiler, it will tell you what part of the code takes up most of the time, this will help a lot.
For GCC (which dev-cpp and code::blocks uses) there is gprof, it's very easy. I don't know what msvc has if that's what you use, but I'm sure there's something nice in there.

Share this post


Link to post
Share on other sites

This topic is 4202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this