|
Speed of clearing a working area on a bitmap |
dthompson
Member #5,749
April 2005
|
I use 'working bitmaps' for quite a lot of my effects - for example, merging overlapping primitives before drawing them with reduced opacity: al_set_target_bitmap(tmp); al_draw_filled_rectangle( 0, 0, 20, 20, al_map_rgb_f(1,0,0)); al_draw_filled_rectangle( 0, 10, 20, 30, al_map_rgb_f(0,1,0)); al_draw_filled_rectangle(10, 0, 30, 20, al_map_rgb_f(0,0,1)); al_set_target_backbuffer(disp); al_draw_tinted_bitmap(tmp, al_map_rgba_f(1,1,1,0.5), 0, 0); Here, tmp needs to be cleared to 100% transparency before each draw. The most trivial way of doing this would be: al_clear_to_color(al_map_rgba_f(0,0,0,0)); 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? ______________________________________________________ |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Do yourself a favor and get out gdb. Set a breakpoint in al_clear_to_color and al_draw_filled_rectangle and step into the function and see what it does on the OpenGL / DX layer. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
SiegeLord
Member #7,827
October 2006
|
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 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I doubt there's any faster way than just to use glClear. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
dthompson
Member #5,749
April 2005
|
"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 ______________________________________________________ |
Peter Hull
Member #1,136
March 2001
|
I'd go for al_clear_to_color - the code looks fairly straightforward: Which calls out to this in OpenGL: This in DirectX And this for memory bitmaps (and also locked OpenGL bitmaps) You could do the same for al_draw_filled_rectangle TBH I doubt either would be disastrously slow...
|
|