al_register_bitmap_loader( ".ext", ?*(*al_loader_fnxn)? )

The title refers to the unknown second argument desired by the al_register_bitmap_loader() function. In fact, the documentation and the MSVS snippet auto-completer disagree on exactly what it wants, the former designating an "ALLEGRO_BITMAP *(*loader)(const char *filename)"; the latter demanding an "ALLEGRO_IIO_LOADER_FUNCTION loader". I assume that these types are identical, though how this is so is beyond my ken, and all attempts to satisfy the wanton desires of this function have proven fruitless.

So I am asking for someone to explain in clear terms the reason why this function was implemented and how to provide it an argument which allows me to make use of it. ( I am aware that the NULL pointer allows you to compile without error, but it still precludes actual use of it to load bitmaps, which is the whole idea. )

RPG Hacker

I'd assume you just need to pass it any pointer to a function that returns and ALLEGRO_BITMAP* while taking a const char*. This would make most sense, if you think about it.

As an example:

1ALLEGRO_BITMAP* load_psd_file(const char* filename) 2{ 3 /* Code for loading a PSD file here */ 4} 5 6int main() 7{ 8 /* Allegro initialization code here */ 9 10 al_register_bitmap_loader(".psd", &load_psd_file); 11 12 ALLEGRO_BITMAP* bitmap = al_load_bitmap("GameDataFolder/MyTestBitmap.psd"); 13 14 /* Draw bitmap to screen here */ 15 16 /* Free resources here */ 17 18 return 0; 19}


Thank you for the help! It has kicked the ball further down the field. I do have a resulting problem I would like to know the answer to, however: namely, Doesn't allegro supply the code for loading images? If this is so, I must be using the wrong method of loading them.

RPG Hacker

Yes, it has code for a few image formats included already, such as png. You have to init the image addon to use them.

Thread #615593. Printed from