Sign in to follow this  

IMG_Load - fails in debugger, succeeds without [SOLVED]

This topic is 4094 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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]

Share this post


Link to post
Share on other sites
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 :(

Share this post


Link to post
Share on other sites

This topic is 4094 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this