Okay well I'm having some problems making my program draw bitmaps. The program compiles fine and starts to run but when It gets to the main game loop where it needs to draw the scene it crashes with a runtime debug error.
Here is the main C++ file:
I have tried all I can think of and nothing works I just get errors all over the place. Please understand this is not nearly done, I'm just trying to make it display some bitmaps before I can push forward with development and add sound, networking, and input code. Please Help!!!!! I truly cant understand why I'm getting this error
The problem seems to be in the function LoadBitmapFromFile. When you set the BITMAP pointer to the loaded bitmap, it's not actually changing the pointer you passed. Instead, you should change the parameter to a BITMAP **bmp (pointer to a pointer), or return the loaded bitmap.
Try something like this:
BITMAP *LoadBitmapFromFile(const char* filepath, const char* errMSG) { debug("Bitmap is going to be loaded from load_bitmap"); BITMAP *bmp = load_bitmap(filepath, NULL); debug("bitmap has been loaded from load_bitmap"); if (!bmp) { alert(errMSG); return NULL; } debug("bitmap returning loaded bitmap"); return bmp; }
This is pretty basic stuff... perhaps you should read a few C tutorials before you start such a project.
[edit]
Just to clear it up, a pointer is just a variable that stores the address of another variable. (And of course it has slightly different syntax).
If you had, lets say, variable "int a", and you set it to equal, variable "int b" (as in a = b), later changing the value of b would not also change the value of a. That is essentially what was happening in your function.
Thank you I shall give that one a try.
[EDIT]
Um, in response to your edit I would like to belive I know a little bit more about allegro and programming then I led you to belive. I do know what a pointer is and how to use one, but thank you anyways, and your solution was correct. I'm still not a pro at allegro but now that I have this fixed out I can go back to my first love, network programing.