al_draw_bitmap fails to run on threads other than the parent thread
I'm thought it'd be wise to have the drawing code of my game run on a separate thread for obvious performance reasons. After several attempts at this i decided to experiment and just run calls of al_draw_bitmap on a separate thread. Here is the code I used for this:
This fails with the error: Assertion failed: (src), function al_copy_transform, file /Users/iam_donald/Downloads/allegro/src/transformations.c, line 32.
Calling draw_video_frame() works. My question is: Is this behavior by design or I am I doing something silly here? Currently this behavior doesn't allow running any chunk of code with calls to al_draw_bitmap on a thread other than parent thread.
A single display cannot be current for multiple threads simultaneously. If you need to release a display, so it is not current for the calling thread, call al_set_target_bitmap(NULL);
So set the parent's target bitmap to NULL and set the child's to the display's back buffer.
Thread #610506. Printed from Allegro.cc
That explains it. Thanks.