So I'm using Allegro 5 in VS2015 and gave the package loaded from NuGET. I also have the image addon installed in my solution.
We can assume that al_init(); al_init_image_addon(); has been called properly and I can draw to the display OK?
I run the following code:
output:
HAH, Fooled you, I didn't actually load jack! :D
So, yea, it "loads" the file with no errors and yet my gui bitmap is still strangely NULL? Let's look at the allegro log!
d3dx9 I d3d_d3dx9.cpp:88 _imp_load_d3dx9_module_version [ 0.06907] Module "d3dx9_43.dll" loaded. stdio D file_stdio.c:109 file_stdio_fopen [ 0.06919] opening gfx\gui.png rb
It loaded! It loaded and.. what? What's going on?
]]>You can check if the file is where you expect it to be by trying al_filename_exists first on it.
]]>The problem isn't the file isn't found. Its that the file is being loaded by the allegro system, and then never assigned to the bitmap pointer.
Just to oblige this theory, I'll change the code a bit.
void load_gfx(void) { if (al_filename_exists("gfx\\gui.png")) { printf("filename is there!\n"); } if (!al_load_bitmap("gfx\\gui.png", gui)) { printf("failed to load gui!\n"); } if (gui == NULL){ printf("HAH, Fooled you, I didn't actually load jack!\n"); } }
I get
filename is there! HAH, Fooled you, I didn't actually load jack!
and my log file looks like this
stdio D file_stdio.c:109 file_stdio_fopen [ 0.13417] opening gfx\gui.png rb d3d D d3d_disp.cpp:1188 real_choose_bitmap_format [ 0.13442] Fake format d3d D d3d_disp.cpp:1188 real_choose_bitmap_format [ 0.13444] Fake format ...
----------------
If I remove the png file from my filesystem and run it, I'll get this...
failed to load gui! HAH, Fooled you, I didn't actually load jack!
and the log looks like this..
stdio D file_stdio.c:109 file_stdio_fopen [ 0.12894] opening gfx\gui.png rb bitmap W bitmap_io.c:211 al_load_bitmap_flags [ 0.12898] Failed loading gfx\gui.png with .png handler.
----------------
So why is the system physically loading my .png file and not assigning it as a bitmap?
This will probably hurt, but the syntax (API) is gui=al_load_bitmap("gfx\\gui.png"), not al_load_bitmap("gfx\\gui.png", gui)
Sorry.
ALLEGRO_BITMAP *al_load_bitmap(const char *filename)
Yea, I need to stop reading API documentation at 3:00am :/
]]>Wondering why the compiler didn't spit out compile error on al_load_bitmap("gfx\\gui.png", gui) since there is an extra argument.
]]>I just had to log in at work to ask the same thing...
"Wait a minute, I was giving it two arguments! That should of been a full stop compile time error."
My guess is it's using some funny formatting things ala printf();
I bet you al_load_bitmap("%s", filestring) works...
]]>