Hello.
Generally I'm new to Allegro library. I'm also new to these forums, so Hello everyone!
I'm Carl, I'm from Poland and currently working on a MMORPG game.
I've been investigating different ways of accelerating map (2D) rendering and found this: https://www.allegro.cc/manual/5/al_hold_bitmap_drawing. I've implemented this idea in my code aand...
My question is... am I doing it in the right way? Here's my code:
Hello Carl. Welcome to the forum! Yes, that looks right. Although it might be better to move al_hold_bitmap_drawing() outside of the for loops, depending on what your aim is.
Unless your bitmaps are all sub-bitmaps of the same parent bitmap, al_hold_bitmap_drawing won't have any effect btw.
Hello Carl. Welcome to the forum! Yes, that looks right. Although it might be better to move al_hold_bitmap_drawing() outside of the for loops, depending on what your aim is.
Thanks! Tiles are grouped by the bitmap ID they are using, so I thought it would be good to enable and disable al_hold_bitmap_drawing() for tiles of each bitmap. Wouldn't it? Would it have same effect if I enable it just once before drawing all tiles?
Unless your bitmaps are all sub-bitmaps of the same parent bitmap, al_hold_bitmap_drawing won't have any effect btw.
I appreciate your opinion. I would use same parent bitmap for all of them although it would require merging 100's of bitmaps I don't think I can use such big bitmap.
If you use a couple large sprite sheets or tile maps, you can group them together on one large atlas texture. Then allocate each image a sub bitmap of an area on that larger atlas. This is where al_hold_bitmap_drawing comes in, because it can delay drawing as long as the bound context doesn't change. So you can happily blit millions of sprites as long as they are on the same texture.
I appreciate your opinion. I would use same parent bitmap for all of them although it would require merging 100's of bitmaps I don't think I can use such big bitmap.
Well, I overstated that - there will be no affect if none of the bitmaps is a sub-bitmap - it does not have to be a single parent.
If I understand right you actually are grouping your al_hold_bitmap_drawing calls around bitmaps with the same parent, in which case you are using it exactly as intended. And in that case it doesn't matter if you call it once around both loops or inside each loop - basically all "held" bitmaps are drawn whenever one of two things happens:
1. al_hold_bitmap_drawing(false) is called
2. a bitmap with a different parent is drawn
If I understand right you actually are grouping your al_hold_bitmap_drawing calls around bitmaps with the same parent
Yes exactly.
And in that case it doesn't matter if you call it once around both loops or inside each loop - basically all "held" bitmaps are drawn whenever one of two things happens:
1. al_hold_bitmap_drawing(false) is called
2. a bitmap with a different parent is drawn
Big thanks to you for sharing this information.
Regards
Carl