Slow tilemap rendering

Hi there!

I?m coding a 2D graphics engine, but it seems my tilemap system isn?t very
effective.
It is more or less based on RPG Maker?s system, that is, all tiles have the
default size of 32 x 32 pixels.
When first starting the game, a list of tiles is loaded from a .txt, and for
each one of them a TileInfo object is created with some info such as how
many layers the tile has, from which file its image can be loaded and so on.
I put all these TileInfo objects into a global STL vector. This works well.
Then, if the system requests the creation of a TileMap object, I read
another .txt where there is a description of exactly which tile goes where,
and using the info from the STL TileInfo vector, a vector of Tile objects is
loaded. Each Tile has a pointer to a vector of Frames (since a tile can be
animated). Each Frame has a pointer to a SDL_Surface. However, if all tiles
come from a single file (with many images on it, like a tile set), all
pointers to SDL_Surfaces point to the same surface, so as not to waste
memory. This is the case on the example I?m testing right now.
Well, all of this works. BUT when I render the TileMap object, it takes
about 2 or 3 seconds to blit all tiles to the 640 x 480 screen I?m using.
This is somewhat expected because there are about 300 tiles to blit. But too
slow. Any ideas?

Thanks,
Carol_________________________________________________________________
Insta-le j? o Windows Live Messenger http://get.live.com/messenger/overview

Hello !

I?m coding a 2D graphics engine, but it seems my tilemap system isn?t
very effective. It is more or less based on RPG Maker?s system, that is,
all tiles have the default size of 32 x 32 pixels. When first starting the
game, a list of tiles is loaded from a .txt, and for each one of them a
TileInfo object is created with some info such as how
many layers the tile has, from which file its image can be loaded and so
on. I put all these TileInfo objects into a global STL vector. This works
well. Then, if the system requests the creation of a TileMap object, I
read another .txt where there is a description of exactly which tile goes
where, and using the info from the STL TileInfo vector, a vector of Tile
objects is loaded. Each Tile has a pointer to a vector of Frames (since a
tile can be animated). Each Frame has a pointer to a SDL_Surface. However,
if all tiles come from a single file (with many images on it, like a tile
set), all pointers to SDL_Surfaces point to the same surface, so as not to
waste memory. This is the case on the example I?m testing right now. Well,
all of this works. BUT when I render the TileMap object, it takes about 2
or 3 seconds to blit all tiles to the 640 x 480 screen I?m using. This is
somewhat expected because there are about 300 tiles to blit. But too slow.
Any ideas?

Did you convert all the Surfaces to the
Display Mode to speed up blitting ?

CU

Yeah I did =)

Carol.>From: “Torsten Giebl”

Reply-To: “A list for developers using the SDL library.
(includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Slow tilemap rendering
Date: Tue, 25 Jul 2006 23:06:08 +0200 (CEST)

Hello !

I?m coding a 2D graphics engine, but it seems my tilemap system isn?t
very effective. It is more or less based on RPG Maker?s system, that is,
all tiles have the default size of 32 x 32 pixels. When first starting
the
game, a list of tiles is loaded from a .txt, and for each one of them a
TileInfo object is created with some info such as how
many layers the tile has, from which file its image can be loaded and so
on. I put all these TileInfo objects into a global STL vector. This
works
well. Then, if the system requests the creation of a TileMap object, I
read another .txt where there is a description of exactly which tile
goes
where, and using the info from the STL TileInfo vector, a vector of Tile
objects is loaded. Each Tile has a pointer to a vector of Frames (since
a
tile can be animated). Each Frame has a pointer to a SDL_Surface.
However,
if all tiles come from a single file (with many images on it, like a
tile
set), all pointers to SDL_Surfaces point to the same surface, so as not
to
waste memory. This is the case on the example I?m testing right now.
Well,
all of this works. BUT when I render the TileMap object, it takes about
2
or 3 seconds to blit all tiles to the 640 x 480 screen I?m using. This
is
somewhat expected because there are about 300 tiles to blit. But too
slow.
Any ideas?

Did you convert all the Surfaces to the
Display Mode to speed up blitting ?

CU


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Descubra aqui como mandar Torpedos Messenger!
http://www.msn.com.br/artigos/maguire/default.asp
http://www.msn.com.br/artigos/maguire/default.asp

BUT when I render the TileMap object, it takes
about 2 or 3 seconds to blit all tiles to the 640 x 480 screen I?m using.
This is somewhat expected because there are about 300 tiles to blit.

This is slow.
I would rather expect a lot less than a 1/10th of a second
unless you use a computer older than 10 years.

Without more information its hard to guess why your system is so slow.

Which OS are you on?
What Video format are you using?
Are your source surfaces converted to the display format?
If your app fullscreen or window?
HW or Soft surface?

Cheers
Gunnar

Well, all of this works. BUT when I render the TileMap object, it takes
about 2 or 3 seconds to blit all tiles to the 640 x 480 screen I?m using.
This is somewhat expected because there are about 300 tiles to blit. But too
slow. Any ideas?

First, make sure they are copy blits and not doing any transparency (alpha/RLE)
Second, which it sounds like you’ve already done, check to make sure they are
the same format as the screen, and that the screen surface itself is the same
format as your display.

And third, this is just for my curiousity, if you’re running on Windows or
Mac OS X, try the SDL 1.3 snapshot: http://www.libsdl.org/tmp/SDL-1.3.zip

See ya!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

And third, this is just for my curiousity, if you’re running on Windows or
Mac OS X, try the SDL 1.3 snapshot: http://www.libsdl.org/tmp/SDL-1.3.zip

Note that to get the best performance from 1.3, you’d need to use the
texture API… take a look at test/testsprite2.c for an example of this.

See ya!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Well, my problem is solved now. It turned out that I was using a very low
FPS value for animated tiles, but the specific tile I was using for testing
didn?t really have an animation. So every time the system called the TileMap
rendering function, SDL_GetTicks() slowed everything down.
Anyway I?m going to test SDL 1.3. And also, I?d like to know:
1.Why is it that SDL_SRCCOLORKEY and SDL_RLEACCEL flags slow things down
(that?s what Sam said,right?)
2.Is there an actual dfference in changing the command order for SDL_Delay()
and SDL_Flip()?

Thanks,
Carol.>From: Sam Lantinga

Reply-To: “A list for developers using the SDL library.
(includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Slow tilemap rendering
Date: Tue, 25 Jul 2006 14:57:54 -0700

And third, this is just for my curiousity, if you’re running on Windows
or
Mac OS X, try the SDL 1.3 snapshot:
http://www.libsdl.org/tmp/SDL-1.3.zip

Note that to get the best performance from 1.3, you’d need to use the
texture API… take a look at test/testsprite2.c for an example of this.

See ya!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Insta-le agora o Windows Live Messenger
http://get.live.com/messenger/overview

You could try openGL …read in image as texture & display a textured quad of same size as image…i am doing that right now because sdl does not support alpha blending…& with opengl you get scaling/transparency/rotation & TRIPLE frame rate.PLUS cpu is left for other things like music ,AI etc as the GPU engages & takes the load of display…of course you keep SDL for other things.For too many images with blending etc SDL is just not there yet.PLUS 3D h/w can reasonably be assumed to be present on most gaming machines these dayz :slight_smile:

ps:man i know i’ll get killed for this!!..but its a fact

Sam Lantinga wrote: > Well, all of this works. BUT when I render the TileMap object, it takes

about 2 or 3 seconds to blit all tiles to the 640 x 480 screen I???m using.
This is somewhat expected because there are about 300 tiles to blit. But too
slow. Any ideas?

First, make sure they are copy blits and not doing any transparency (alpha/RLE)
Second, which it sounds like you’ve already done, check to make sure they are
the same format as the screen, and that the screen surface itself is the same
format as your display.

And third, this is just for my curiousity, if you’re running on Windows or
Mac OS X, try the SDL 1.3 snapshot: http://www.libsdl.org/tmp/SDL-1.3.zip

See ya!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Abhijit


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min.