Hey, everyone,
I've been teaching myself C++ for the past week, although I've been coding and tinkering with games for almost 16 years. I'm comfortable with the C++ syntax already and have been chugging along fine, but I've hit a bit of a snag. I'm using CodeBlocks 17.12, SDL 2.0.8, and SDL Image 2.0.3, and I am trying to load a PNG file in for use as a sprite. I have SDL linked perfectly fine, and have been messing around with it's commands for a couple of days with no problems. Loading BMPs, editing pixel matrices, getting user input, basic loop timing and flow, etc. Yesterday, I tried to install SDL Image, and I have the library installed to the point that CodeBlocks can pick up it's syntax and I can use auto finish on it's commands, and there are no compilation errors. The problem comes when I run my code. Through process of elimination(thanks to my in-built error checking), I have narrowed it down to this code:
/*** -INITIALIZE PNG LOADING- ***/
int flags=IMG_INIT_PNG;
int initted=IMG_Init(flags);
if((initted&&flags) != flags)
{
SDL_Log("Unable to initialize image load: %s", IMG_GetError());
return EXIT_FAILURE;
}
/*** -LOAD IMAGES- ***/
SDL_Surface *image;
SDL_RWops *rwop;
rwop=SDL_RWFromFile("\media\die.png", "rb");
image=IMG_LoadPNG_RW(rwop);
if(!image)
{
SDL_Log("Unable to initialize load image: %s", IMG_GetError());
return EXIT_FAILURE;
}
If I comment block all the Load Images part it runs(even with the PNG Loading part still in), but if I dont, it exits due to the error.
After digging around to see what could be wrong I went to the SDL Image website to read that PNG files may need libPNG and zlib. I tried for hours to install those two libraries, but it looks like no matter which archive I download it's just full of UNIX garbage that I can't use on Windows. This, however, doesn't seem to be the path I needed to take, as through testing BMPs do the same thing(Which SDL Image says should load natively). I don't know if there is an error in my code, or if I need libPNG and zlib. I'm lost here.
Help would be greatly appreciated, thanks,
-Omerta