I'm using SDL, so if I'm not meant to be asking for help with that here let me know I'll post somewhere else.
I'm not sure why this isn't working; it compiles fine on my mac but then when I try it on windows it doesn't seem to load the images properly.
The error message which I get from the function displays the correct filepath (and the file is definately there), so I can't understand why it won't load.
You got lucky (or unlucky, depending on how you look at it) running it on the Mac, since there is an error. You're returning a local variable. You want something more like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void get_directory( char* path ) {
char* c = "/";
#if defined (__WIN32__)
c = "\\";
#endif
getcwd( path, 260 );
strcat( path, c );
}
// Call it like this:
char path[260];
get_directory( path );
strcat( path, filename );
// Then just use filename, no need for a sstream object
Yeah, IMG_Load is the SDL_Image function. The SDL one is SDL_LoadBitmap or something.
I have the libraries set up properly.
Ah, thanks.
I'll give that a go. I had some problems using strcat before.
EDIT:
Well, I tried doing it like that but I got the same problem.
path seems to contain the correct string rather than filename, but the image loading still doesn't work.