Using Code::Blocks,MinGW 4.5.0 GNU-GCC compiler on Allegro 5.0.9
On my windows 7 laptop, when i attempt to draw a bitmap region to the screen such as:
al_draw_bitmap_region(Test,0,0,0,0,1280,720,0);
... It will just crash the program.
I myself do not know any clue as to why it occurs, except the fact that i am attempting to run it on my own computer, and not my school computers. Is there any other variables that could've caused this issue? Perhaps the issue is that the school computers are running windows vista and I am not?
http://pastebin.com/mS3JvRrq
The link above is the code for the game i have that works just fine on the school computers.
//EDIT
Made a new link, should work now sorry about that, i tried to use this sites attachments =/
That link does not work. Attach the code to your post, perhaps...
A couple of things to note:
You should never use absolute paths when loading resources, for example, when you're loading the bitmap J:\\Final Project\\GalagaSprite.bmp. Use a path relative to the binary. Instead, if your executable is in J:\FinalProject, create a folder called J:\FinalProject\bitmaps, and put GalagaSprite.bmp in there. Then use al_load_bitmap("bitmaps/GalagaSprite.bmp"). Not all computers have the same drive letters, nor can you be certain that your program will be installed in the same directory on every computer. This, alone, could be the cause for your problem.
A program doesn't "just crash". What type of error are you getting? If we know what type of error you're getting, that will make things easier to debug.
Allegro has been tried and testing very thoroughly, so it's highly unlikely this is an issue involving Allegro or the operating system specifically.
Hope that helps!
ProjectV0.5 (his code on Pastebin)
Yes, atlasc1 is right - don't use absolute paths. And don't use windows path separators either, use a single forward slash like in Linux.
ALLEGRO_BITMAP* GalagaSprite = al_load_bitmap("Galaga Backgrounds/GalagaSprite.bmp"); if (!GalagaSprite) {cout << "failed to load GalagaSprite" << endl;} // repeat for each bitmap to load.
And you would make sure that your exe is in the same folder as the Galaga Backgrounds folder, and that you have set the current working directory to that folder as well. See al_get_standard_path and al_change_directory for details. Use ALLEGRO_RESOURCES_PATH to get the path.
And one final note, al_draw_bitmap_region won't fail unless your pointer is null or you destroyed it and then tried to draw it again.
Given the boundary conditions you gave us, I also vote for a failure in loading the images, failre that you do not trap.
Alas, you are checking return values...but in the bitter case you fail to load you just print out to the console and go on...nah, it's not safe...program should terminate with an error message.
You may very well NOT have console window open in release mode, IIRC.