I know, I know.. You are going to ask me why am trying to pass a global to a function? Why not just alter the global in my function or just return the pointer?
I'm porting a game that used an index of numbers that kept track of memory buffers holding video memory.. i.e.
#define BUFER1 1
#define BUFER2 2
#define BUFER3 3
and then they load graphics by calling a command like so
LoadPic("background.png", BUFFER3); // LoadPic(char *filename, int buf);
Now I though "Aha! I can make this transparent and change LoadPic() to load Allegro bitmaps into a global space. I'll just change the types like so...
and change the declaration to something like.
Then calling the same exact command will do the same thing right?
But alas, inside Loadpic, I'm losing the scope. *buf us getting the address to the bitmap, but the thing I passed to it, BUFFER3 is not.
Is there an elegant way of doing this? The reason why I'm so keen is that if I can wrap the graphic lib around allegro, I have to do next to nothing to port the code of the game itself...
Maybe there is a way I can use the old index? I'm kinda stuck.