I'm trying to understand why SDL2 compiled for Android can't find the JPG (or bmp,or png) texture file using this code:
/** Prepare textures */
static SDL_Texture *img = NULL;
int w, h; // texture width & height
// load our image
if (img == NULL) {
img = IMG_LoadTexture(state->renderers[0], "background.jpg");
if (img != NULL)
{
SDL_Log("Image loaded ok %s\n", "background.jpg");
} else {
SDL_Log("Error loading Image: %s\n", "background.jpg");
}
I'm adding the background.jpg file in the assets folder of the project and it is added to the APK file, so I don't know what's happening, if you know something i'm missing ...
Ok, the problem was the sdl image library was not being initialized with IMG_INIT(flags) and you have to compile sdl image with load_jpg parameter set in the compiler. Once you do both things you are ready to go