简体   繁体   中英

SDL2_image not initializing

Im trying to load a .png file with SDL2 and SDL2_image. SDL2 initializes properly while SDL2_image just fails for no apparent reason, please help.

IMG_Init() returns 0

IMG_GetError() returns nothing

I'm using SDL2 2.0.10 and SDL2_image 2.0.5 (latest versions afaik) I do have all needed dll files in the same folder as my executable (SDL2.dll, SDL2_image.dll, libpng16-16.dll, zlib1.dll as I'm only using png files right now)

I have no idea why this isn't working and I have been trying to find an answer for at least 2 hours now

My code:

if(IMG_Init(IMG_INIT_PNG) != 0) {

        std::cout << "Failed to init sdl_image"<<IMG_GetError()<<std::endl;
        return 0;
}

正如 HolyBlackCat 指出的那样,它应该是IMG_INIT(IMG_INIT_PNG) != IMG_INIT_PNG而不是IMG_INIT(IMG_INIT_PNG) != 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM