Graphics

Reply

DrawImage() slow

I'm trying to generate a background 'map' using sprite tiles from an Image object and rendering the individual tiles thus :

 

Stopwatch sw=new Stopwatch();
sw.Start();
for(int y = 0; y < MapHeight; y++)
{
   for(int x = 0; x < MapWidth; x++)
 {
        int imgNum = m_MapData[x, y];
m_RenderedMapImage.DrawImage(m_Tiles.Crop(new ImageRect(imgNum*MAP_BLOCK_SIZE,0,MAP_BLOCK_SIZE,MAP_BLOCK_SIZE)), pos);
                    pos.X += MAP_BLOCK_SIZE;
   }
                
   pos.X = 0;
   pos.Y += MAP_BLOCK_SIZE;
}
Console.WriteLine ("Map draw took {0} ms", sw.ElapsedMilliseconds);

 

 

 

But after profiling this for a 19 x 13 tile map (247 tiles) it is taking around 850 ms to render the map image. Is there a more efficient of doing this that I am missing? I have toyed with using a SpriteList but worry about performance at runtime.

 

What is the best way of off-screen rendering?  Can I use GameEngine2D and render a SpriteList to an off-screen graphics buffer?

 

Any help or advise would be greatly appreciated




PSS port of Blitz Bombers
http://blitzbombers.blogspot.com

Please use plain text.

Re: DrawImage() slow

[ Edited ]

The Imaging libraries probably wasn't made for real time stuff, so I'd use SpriteList or RawSpriteTileList. They're made to batch up all the sprites you pass into the list and draw them all in one call (caveat is they all have to refer to the same texture, so your tileset would have to be in one texture), which is something PSS seems to prefer.

 

If your tilemap doesn't change in the scene, you can just call your tilemap drawing thing once and load the image into a texture and just draw that.

Please use plain text.

Re: DrawImage() slow

Thanks for your advice. Curently I do indeed do as you suggest to render the tilemap and load the image into a texture - so for normal gameplay, this works just fine.

The issue with the performance is on the game's configuration page you can customise which 'levels' you want active by tapping a thumbnail preview of the level, and so I thought I could simply re-use the tilemap renderer function and draw a thumbnail of each map onto a gridlist. Sadly it takes about a minute to render 60 thumbnails !

I think for now I will use pre-rendered thumbnails
PSS port of Blitz Bombers
http://blitzbombers.blogspot.com

Please use plain text.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。