Allegro 5 fails to "assert mutex" when doing image = al_create_bitmap(x, x);

I'm trying to create a bitmap.

218void tile::imageLoad() { 219 std::cout << "Loading " << fileName << std::endl; 220 //some code 221 image = al_create_bitmap(NUMBER, NUMBER); 222 //some code 223 std::cout << "Loaded " << fileName << std::endl; 224}

Somehow, as it does image = al_create_bitmap(1, 1);, it gives Assertion failed: mutex, file C:\dev\allegro_winpkg\universal\allegro\src\threads.c, line 310
and aborts. ???
This used to work before, but somehow changing something out both out of this function and out of tile has caused this.


We're going to need more context than that! You're even assigning to a variable that is outside the scope of the function (member variable (Or global ???)).
Of course this code in itself is 100% fine, but a lot more can go wrong before the call to al_create_bitmap.
How do you init allegro? Is Allegro initialized with hardware acceleration support?
Does creating a 64x64 bitmap work?
Copy pasting the code somewhere else to see if that works?
Are you doing crazy multithreaded rendering / was Allegro initialized on another thread?
Are you running out of memory?
Could you have caused memory or heap corruption elsewhere?
If you're really up for an adventure, crack open the Allegro source code and find out how that mutex can be NULL.

Edgar Reynaldo

My guess is you're using a global Tile object, and it's trying to create the bitmap before allegro has been initialized.

But it could be a lot of things. I can't tell you where in the source code that is, because GIT has diverged from 5.2.2 and the sources don't match up anymore.

Edgar Reynaldo

The only reason a mutex wouldn't be valid is because you haven't called al_init first.

Thread #616952. Printed from