Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5] Loading Bitmaps while al_hold_bitmap_drawing() is Engaged

Credits go to pkrcel, SiegeLord, and Todd Cope for helping out!
This thread is locked; no one can reply to it. rss feed Print
[A5] Loading Bitmaps while al_hold_bitmap_drawing() is Engaged
Kris Asick
Member #1,424
July 2001

Very simple question: Can you load bitmaps into video memory while al_hold_bitmap_drawing() is engaged, or is this a very bad idea?

If this isn't possible, I can work around it thanks to al_is_bitmap_drawing_held(), but it would still be nice to know ahead of time. I'm the midst of coding an automatic texture handling system for my game and it just occurred to me that deferred drawing may be going on when texture load requests automatically happen.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Todd Cope
Member #998
November 2000
avatar

I don't see how it could cause a problem, as no rendering occurs until you call al_hold_bitmap_drawing(false). Deferred rendering just builds up a list of vertices and dumps them to the screen when you make that call or attempt to draw something that uses a different texture.

Kris Asick
Member #1,424
July 2001

Well, I'm going by this little snippet from the A5 manual: "While deferred bitmap drawing is enabled, the only functions that can be used are the bitmap drawing functions and font drawing functions."

*shrugs*

--- Kris Asick (Gemini)
--- http://www.pixelships.com

pkrcel
Member #14,001
February 2012

I think that Todd is right from guesswork and logic, but your complain is founded.

Reading from the documentation, it seems implied tha not only blender and render state can't be changed but also loading bitmaps.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

SiegeLord
Member #7,827
October 2006
avatar

I'd follow the recommendation in the manual. In principle we could audit the other functions and see if they continue to work while bitmap drawing is deferred, but until that's done, I'd make no guarantees. In particular, nothing stops the bitmap loaders from using drawing functions as part of loading (e.g. al_put_pixel).

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

Kris Asick
Member #1,424
July 2001

*nods* Given the fact that loading only has to happen once per main texture file unless it's unloaded again at some point, I think erring on the side of caution would be the better approach. Disabling and re-enabling deferred drawing automatically is simple enough and I don't think the average person is going to notice or care if their framerate drops for a fraction of a second when they're first starting up the gameplay. ;)

I'm designing my texture handling system so that I can manually buffer in textures ahead of time if necessary, but for the most part, it will wait until a particular sub-texture is accessed, at which point it loads in the main texture file and parses it into its individual sub-textures. Unloading has to be done manually though, but the system is smart enough not to accidentally load anything twice, or attempt to unload anything which is already unloaded.

I'm building all kinds of generic foundation code right now so that any time I go to make a game in the future I won't have to re-write all this stuff again and again! 8-)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

pkrcel
Member #14,001
February 2012

I agree, not knowing precisely if there would be any effect...errig on the cautious side is okay.

I actually didn't think that loading functions could access drawing functions.

Side question: is it (at least in theory) possible to register a custom bitmap loader that takes care of drawing hold status?

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Go to: