al_save_bitmap_f() in std::thread?

Trying to save some bitmap data from a thread other than the one in which the display was created. (a few hundred images, about 500x200 each, as .BMP)

This seems to be a problem since the save routine needs to lock the bitmap, and the locking routines need to be able to get format data from the current display for the thread (which doesn't exist in my separate thread created specifically for saving bitmaps...)

I've tried to hack together my own version of al_lock_bitmap_region() so that I can just supply the display format as a parameter, but its using the internal definitions of ALLEGRO_BITMAP (and "vt" which is totally foreign to me?) and its obviously a spaghetti code nightmare including the definition of ALLEGRO_BITMAP even if it were to work (and it obviously doesn't.)

I thought about creating a separate display for the new thread, but this isnt very performant and obviously creates a new display which is ridiculous.

I'm totally stuck.

Any bright ideas how I can save copious bitmap data to disk, quickly, from a thread (or otherwise not impacting the more important high framerate loop?)


Do this for each bitmap, on the main thread:

copy[x] = al_clone_bitmap(bitmaps[x]);

And then in your other thread save all the copy[x] bitmaps. Only the main thread can access non-memory bitmaps, so basically create memory-bitmap copies of all bitmaps on the main thread then access those on the other thread.


Life saver :D

I should have tried that. Thank you kindly!

Thread #616599. Printed from