Jump to content
  • Advertisement
Sign in to follow this  
chiranjivi

Tile-based SDL game performance issues

This topic is 2592 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 all,

I've written a little tile-based scrolling platformer in SDL and have run into some performance issues. The game's tileset is 24x24, so a large number of tiles are being drawn to the screen every frame. At 30fps, and at a low resolution like 800x600, performance is okay, but if I try to raise the resolution to something more reasonable like say, 1280×1024 (and ~54x43 tiles visible at once as opposed to ~34x25), the application hits 100% usage of the CPU core it's on and begins to slow down :(

Stuff I've read about speeding up SDL in this regard recommends converting surfaces to the screen format when loading them (I've done this), and avoiding redrawing parts of the screen where possible, which isn't really practical in this case - if the player is in motion, pretty much the entire screen needs to be redrawn every frame as the play area scrolls.

If anyone has any pointers as to how I can improve things I would be very grateful to hear them.

Share this post


Link to post
Share on other sites
Advertisement
1280x1024 is a lot of data to be copying to the screen every frame. Have you tried using hardware surfaces? Note that you might need to do some extra work to actually get hardware surfaces, because the default SDL backends on the popular platforms don't support it. So on Windows, you'd need to specify that you want a directx backend.

Bob Pendleton's SDL articles are highly recommended.

If you really need a high resolution, you might be better off using OpenGL rather than SDL's rendering API.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!