Skip to main content
GameDev.net gamedev.net
🔒 Locked

Tiling in SDL

Started by Jazonxyz Feb 19, 2009 at 5:27 PM 8 replies 2.1k views
Original Post
Jazonxyz
Jazonxyz
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?
OniLink10
OniLink10
Are you using the Tutorials on http://www.lazyfoo.net/ ?
Jazonxyz
Jazonxyz
Yeah, but thats not fast enough. The code at lazy foo is for teaching purposes, thats why its not really optimized.
OniLink10
OniLink10
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?
Jazonxyz
Jazonxyz
It takes 30% of my processor just to render the map at 20 fps.
OniLink10
OniLink10
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.
rip-off
rip-off
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?
samuraicrow
samuraicrow
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.
Jazonxyz
Jazonxyz
omg! Samuraicrow, you just answered what I was looking for!

Thank you! ;-)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.