Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Speed of clearing a working area on a bitmap

This thread is locked; no one can reply to it. rss feed Print
Speed of clearing a working area on a bitmap
dthompson
Member #5,749
April 2005
avatar

I use 'working bitmaps' for quite a lot of my effects - for example, merging overlapping primitives before drawing them with reduced opacity:

Here, tmp needs to be cleared to 100% transparency before each draw. The most trivial way of doing this would be:

Alternatively, I could blank the area needed with a rectangle:

al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
al_draw_filled_rectangle(0, 0, 30, 30, al_map_rgba_f(0,0,0,0));

So, let's say I made the (perhaps poor) decision to clear a working area many times in my draw code. Given that al_clear_to_color ignores blending and transforms, I'm wondering whether it might be better-optimised than the primitives, despite the larger fill area.

Could someone with knowledge of Allegro's internals give me a hint as to what might be universally faster?

______________________________________________________
Website. It was freakdesign.bafsoft.net.
This isn't a game!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

SiegeLord
Member #7,827
October 2006
avatar

I suspect clear is significantly faster given how much is necessary to accomplish the primitive drawing from Allegro's side.

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

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

dthompson
Member #5,749
April 2005
avatar

"just getting out gdb" would be fine for my specific case, but 'universal' is the operative word here; I had no idea whether some internals would run faster/slower on specific backends, OSes, or cards. For whatever reason.

From what SiegeLord is saying, though, clear sounds like it's always going to be faster. Ta ;)

______________________________________________________
Website. It was freakdesign.bafsoft.net.
This isn't a game!

Peter Hull
Member #1,136
March 2001

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: