0

Alright so I'm trying to make a game engine for myself, and I've decided that it would be best to start loading images as files other than bitmaps using the SDL Image library. I've set up the library correctly according to conversations online, include set up and linker set up, and yet when I try to load a file that does indeed exist it just returns an empty surface.

Heres the code loading the file...

SDL_Surface* background = IMG_Load("Assets/bg.png");
background = SDL_ConvertSurface(background, mtrx->format, 0);
if (!background) {
    ofstream file("text.txt");
    file << IMG_GetError() << endl;
    file.close();
}

...And the error I get in "text.txt"...

Parameter 'surface' is invalid

At the beginning of the script I have included SDL.h, then SDL_image.h, and the window initiation has IMG_Init(IMG_INIT_PNG) after SDL_Init. Visual studio shows no errors whatsoever, and everything BUT IMG_Load works fine.

All help would be appreciated, and I can provide any other code that might be helpful!

  • 2
    Have you checked the result and error code of `IMG_Load` rather than `SDL_ConvertSurface`? As you are using relative paths are you sure the working directory for your program is correct? – Alan Birtles Feb 23 '20 at 10:36
  • @AlanBirtles I'll check if removing convertsurface gets a different error code, but I have tried different variations of the filepath and I'm mostly sure that is not the issue –  Feb 23 '20 at 11:10
  • @AlanBirtles that did change the error! I've now got "Failed loading libpng16-16.dll: The specified module could not be found." -which is strange, because I have dropped the included dll from where I downloaded sdl image from... Ill try looking for another download online and hope it works! –  Feb 23 '20 at 11:12

0 Answers0