Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » performance of sub-bitmaps

Credits go to Dizzy Egg and SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
performance of sub-bitmaps
Peter Hull
Member #1,136
March 2001

noob question of my own!
If I have a load of small bitmaps to draw, it is, as I understand it, a good idea to put these all on one bigger bitmap and blit regions of it (a texture atlas I think is the term)
I could do this by keeping my own list of rectangles and al_draw_bitmap_region or I could create sub-bitmaps and just al_draw_bitmap them. As far as I know, all sub-bitmaps share the same backing bitmap but just apply a region automatically.
Are these the same thing performance-wise or are there other issues to consider?

SiegeLord
Member #7,827
October 2006
avatar

They're the same thing when drawing them, performance wise. Here's literally the totality of the code difference between drawing a bitmap, or its sub-bitmap:

   if (bitmap->parent) {
      parent = bitmap->parent;
      sx += bitmap->xofs;
      sy += bitmap->yofs;
   }

The only difference I can think of is that your custom rectangle will probably be more lightweight than a bitmap (e.g. every bitmap sets up an orthographic transform just in case its ever used as a target bitmap). But that shouldn't be a huge difference.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Dizzy Egg
Member #10,824
March 2009
avatar

On the KrampusHack I used al_hold_bitmap_drawing for the first time, and noticed a massive improvement when using a large bitmap and drawing regions from it. It was probably just in my brain but it seemed a bit faster than using subs. Given SiegeLords reply it was probably just background processes changing at the time of testing. The only thing that enforced it was that I was using OpenGL, and thought maybe it was a specific thing to that.

I suppose the only useful thing to take from that rant is that al_hold_bitmap_drawing is cool.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Peter Hull
Member #1,136
March 2001

Good shout on al_hold_bitmap_drawing I'd forgotten all about that. I'm not really close to having to worry about speed but, if I've time, I'll do some benchmarks to see what difference it makes.

tobing
Member #5,213
November 2004
avatar

The full performance comes with sub-bitmaps, hold bitmap drawing and HW acceleration. :)

Go to: