Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 15 Jan 2000
Offline Last Active Oct 01 2013 12:15 PM

Topics I've Started

Problem Loading PNGs with SDL_image on Windows

08 July 2012 - 12:37 PM

I am trying to make a Windows version of a game that uses SDL and SDL_image. The game's image files are PNG files. I am using SDL 1.2.15 and SDL_image 1.2.12. I compiled a release version of my game using Visual C++ 2008 Express on a 32-bit Vista virtual machine. The game builds with no errors. I create a Release version of the game and add the following files to the same directory as the executable file:

The PNG files

The dll files are the x86 versions from the SDL and SDL_image binary installations.

When I run the game from outside Visual C++, a window opens and the game crashes. Stepping through the code in the debugger, I discovered the following code returns a null pointer:

SDL_RWops* textureFile;

// filename is the argument I pass to the texture loading function.
textureFile = SDL_RWFromFile(filename, "rb");

Adding a call to SDL's GetError functions to get more information about the error provides the error message "Couldn't open ImageFile.png", where ImageFile is one of the PNG files in the game. I figure the files aren't loading due to not having the PNG files or DLLs in the right location. But I thought putting them in the same location as the application was enough to get the image files to load. Are there additional libraries or files I need to place in the application folder to get the PNG files to load? I'm obviously missing something.