|
al_load_bitmap() pretends to load a file. |
nshade
Member #4,372
February 2004
|
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: 1void load_gfx(void)
2{
3 if (!al_load_bitmap("gfx\\gui.png", gui)) {
4 printf("failed to load gui!\n");
5 }
6 if (gui == NULL){
7 printf("HAH, Fooled you, I didn't actually load jack! :D\n");
8 }
9}
output: 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? |
SiegeLord
Member #7,827
October 2006
|
You can check if the file is where you expect it to be by trying al_filename_exists first on it. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
nshade
Member #4,372
February 2004
|
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.
---------------- |
Audric
Member #907
January 2001
|
This will probably hurt, but the syntax (API) is gui=al_load_bitmap("gfx\\gui.png"), not al_load_bitmap("gfx\\gui.png", gui) |
nshade
Member #4,372
February 2004
|
ALLEGRO_BITMAP *al_load_bitmap(const char *filename) Yea, I need to stop reading API documentation at 3:00am :/ |
DanielH
Member #934
January 2001
|
Wondering why the compiler didn't spit out compile error on al_load_bitmap("gfx\\gui.png", gui) since there is an extra argument. |
nshade
Member #4,372
February 2004
|
I just had to log in at work to ask the same thing... My guess is it's using some funny formatting things ala printf(); I bet you al_load_bitmap("%s", filestring) works... |
|