IMG_Load - fails in debugger, succeeds without [SOLVED]

Started by
1 comment, last by rogierpennink 17 years, 6 months ago
[EDIT]: Solved, it all boiled down to a simple, stupid, wrong working directory Original Message: ------------------------------------------------------------------------------- Hey, I think the topic title must have explained a lot already, but I'll re-explain anyway [grin]. Somehow, when I run the debug version with the Visual C++ debugger, the IMG_Load function from SDL_image won't work. All the surfaces that are loaded with it remain NULL pointers. The strange thing is, however, that as soon as I simply open the folder in which the .exe is located and double click on the application from there, it works fine, no problems at all. All images are displayed exactly as they should as well. Is there anyone who has a clue about what might be the underlying cause of this (I don't know my IDE well enough, it seems)? Normally I wouldn't bother debugging, but there's something else I need to debug in the application, and this image loading thing in debug mode prevents that. Underneath is my image loading method:

SDL_Surface * LoadImage ( std::string filename )
{
	SDL_Surface *temp1 = NULL;
	SDL_Surface *temp2 = NULL;

	temp1 = IMG_Load ( filename.c_str() );
	
	if ( temp1 != NULL )
	{
		temp2 = SDL_DisplayFormat ( temp1 );
		SDL_FreeSurface ( temp1 );
	}

	return temp2;
}



Thanks in advance for any help. - Rogier [Edited by - rogierpennink on October 1, 2006 2:33:44 PM]
Advertisement
Maybe working directory in debugger settings in project properties points to wrong directory?
On your suggestion I explicitly set the working directory to the Debug folder of the project, however, the images still won't load when debugging. (The images are in "media/images/", relative to the debug folder). Does the debugger require me to put all image files in the same directory or something?

Edit: I actually did that and it didn't work either :(

This topic is closed to new replies.

Advertisement