Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

IMG_Init causes trouble #3

Open
SafwatHalaby opened this issue Apr 8, 2015 · 4 comments
Open

IMG_Init causes trouble #3

SafwatHalaby opened this issue Apr 8, 2015 · 4 comments

Comments

@SafwatHalaby
Copy link

    int imgFlags = IMG_INIT_PNG;
    if( !( IMG_Init( imgFlags ) ) )
    {
        printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
        return false;
    }

This will always print the following message to the console

SDL_image could not initialize! SDL_image Error: PNG images are not supported

Interestingly, simply not calling IMG_Init makes everything work in Emscripten.
Even more interestingly, whether one calls IMG_Init or not has no effect at all in NATIVE sdl2.

I don't know what to make of it.
But at the very least, the Emscripten port should spit something like "You don't need to call IMG_Init" rather than just throw a confusing unrelated error.

@kripken
Copy link
Member

kripken commented Apr 8, 2015

I'm not sure at this point how we are building SDL image. I guess we aren't linking in libpng, and instead rely on browser decoding, which is asynchronous. I assume that's the reason for this confusion, but I'm not sure.

@SafwatHalaby
Copy link
Author

PNG's are not the specific cause. Swap the flag with int imgFlags = IMG_INIT_WEBP and you'd get the same error, WEBP images are not supported, this is true for any flag.

@SafwatHalaby
Copy link
Author

And by the way, all image types are in fact supported, as long as the user does not call IMG_init.

@kripken
Copy link
Member

kripken commented Oct 9, 2015

emscripten-core/emscripten#3831 addresses part of this, by giving an option to use libpng etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants