I am following a tutorial and I think I have done everything right, but it continues saying "Unsupported image format".
The code:
SDL_Texture *LoadTexture(string filePath, SDL_Renderer *renderTarget)
{
SDL_Texture *texture = nullptr;
SDL_Surface *surface = IMG_Load(filePath.c_str());
if (surface == NULL)
{
cout << "Error: " << IMG_GetError() << endl;
}
else
{
texture = SDL_CreateTextureFromSurface(renderTarget, surface);
if (texture == NULL)
{
cout << "Error: " << SDL_GetError() << endl;
}
}
SDL_FreeSurface(surface);
return texture;
}
The surface stays NULL after it accepts the result of IMG_Load();
Also, my includes:
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL/SDL_image.h>
And, my initialization:
SDL_Init(SDL_INIT_VIDEO);
int image_flags = IMG_INIT_PNG;
if (IMG_Init(image_flags) != image_flags)
{
cout << "Error: " << IMG_GetError() << endl;
}
Also, in case it matters, I am doing this in Ubuntu and I recently switched from Windows, so I may not be doing something with the libraries correctly.
Edit: If you would ask, I am trying to work with a PNG, so I am not using a format that I haven't initialized