I'm working on loading a tile set into a single bitmap, and then drawing regions of this bitmap as required. It was the simplest and most straightforward approach.

But I seem to be having a problem. I've saved the tile set into a custom format made with TileStudio (which is awesome by the way), and so I've written code that loads it into an Allegro5 bitmap structure. I do this by creating a new bitmap, and then loading the pixel colour components from the file and using al_put_pixel. Now I know this all works, because I've seen it.

But it gets to when I'm actually creating the bitmap. Sometimes (most of the time but not all) al_create_bitmap will cause a weird exception to be thrown elsewhere in the program. That is, the code will execute until al_create_bitmap, and then it'll throw an exception. But the call stack will in fact point to a different part of the program (some where inside the NSApplication object - I'm using Mac OS X).

I've concluded, but I'm not entirely sure, that this is being caused by me asking for a massive bitmap. 48 tiles, each tile 32x32x32bits. So I was curious if there is an upper limit on the permitted size of a bitmap (independent of the available memory).

That is, the code will execute until al_create_bitmap, and then it'll throw an exception. But the call stack will in fact point to a different part of the program (some where inside the NSApplication object - I'm using Mac OS X).

That's the main thread, but your program runs from a secondary thread. You need to switch to one of the other threads to find the correct point where the program crashes (I can never quite remember which thread I want, but you can easily tell by trying them all because most of the tracebacks will not make sence).

Quote:

I've concluded, but I'm not entirely sure, that this is being caused by me asking for a massive bitmap. 48 tiles, each tile 32x32x32bits. So I was curious if there is an upper limit on the permitted size of a bitmap (independent of the available memory).

Yes, if it's a video bitmap, it must be smaller than the largest texture size. If you do a 32 by 48*32 bitmap, you may overrun that. This is less likely if you do 3*32 by 16*32.

Post backtraces of when it occurs, and try examining local variables in the line of code that crashes. Also, run a debug version of your program linked to the debugging version of Allegro. That will create an allegro.log file that may have some clues as well.

Why don't you post the code you are using? We can't find any errors you might be making without seeing the code you are using. If your code is throwing a std::bad_alloc exception, you are asking for too much memory. Show code.