Jump to content
  • Advertisement
Sign in to follow this  
Shuger

SDL - hardware support and a file format

This topic is 4482 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!