Tile-based SDL game performance issues

Started by
0 comments, last by rip-off 12 years, 5 months ago
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.
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.

This topic is closed to new replies.

Advertisement