Tiling in SDL

Started by
8 comments, last by samuraicrow 15 years, 2 months ago
Well, I'm making a small map demo and its not running as fast as I want it to. What's the fastest way to tile images in SDL? Im using 40x40 tiles in an 800x600 screen, should I use 32x32 in a 640x480 screen?
Advertisement
Are you using the Tutorials on http://www.lazyfoo.net/ ?
Yeah, but thats not fast enough. The code at lazy foo is for teaching purposes, thats why its not really optimized.
Oh, ok. What do you mean by "it's not fast enough", though? Is there noticable lag? Or does it just take a second to load?
It takes 30% of my processor just to render the map at 20 fps.
Quote:Original post by Jazonxyz
It takes 30% of my processor just to render the map at 20 fps.


Are you drawing Tiles even if they aren't on-screen? If so, that would be the problem. Also, if you're using an older Processor, that could cause it too.
Quote:Original post by Jazonxyz
It takes 30% of my processor just to render the map at 20 fps.


Why are you only using 30% of your processor?

Do your tile images contain alpha information?
Keep in mind that on most machines, there is very little blitter support on versions of SDL less than 1.3 (the experimental version).

If you use OpenGL from within SDL 1.2.x you might use less processor time. Unless you're using alpha-blending, image rotation, or realtime scaling, it won't speed up your tiling any more but it will free up some of your processor time.

Also, if you want to use OpenGL tiling, you'll need to use tile sizes that are an even power of two for length and width. 32x32 is a good size but 40x40 won't work on OpenGL due to texture size constraints.

For tile-scrolling demos you might want to check out these SDL examples in particular the smoothscroll-1.1 source.
omg! Samuraicrow, you just answered what I was looking for!

Thank you! ;-)
You're welcome. [smile]

This topic is closed to new replies.

Advertisement