Page 1 of 2
C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Fri Apr 14, 2017 5:18 pm
by domis4
Hello everyone,
i tried to get in touch with c++ for the first time and used one of the vitasdk samples in order to create some basic SDL2 application. Currently, i can't get past image loading using SDL2_image, as the image format is always unsupported no matter what format and properties i use (png, jpg, bmp). The small code behind loading and rendering is:
Code: Select all
SDL_Texture* image = IMG_LoadTexture(gRenderer, path.c_str());
https://github.com/domis4/vita-sdl2-tes ... module.cpp
which throws
and results in an application crash due to texture nullpointer in SDL_RenderCopy().
After some research i thought to include
libpng and
zlib headers and use IMG_init(flags), but the application still throws and crashes.
Maybe a experienced Dev can see my mistake.
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Fri Apr 14, 2017 9:05 pm
by noname120
Your homebrew runs in safe mode, this means that it can only access ux0:data/* and ux0:app/YOURTITLEID/*.
If you're willing to embed resources in your app, add them here:
https://github.com/domis4/vita-sdl2-tes ... ts.txt#L49
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Sat Apr 15, 2017 8:52 am
by domis4
thank you. This should have crossed my mind sooner. I wasn't too sure how i'd embed my assets.
While including it with
Code: Select all
FILE src/assets/test.png assets/test.png
worked like a charm and is totally fine for me, the file got installed to ux0:/app/ap-id/assets/test.png but It still throws Unsupported Image format using either
app0:assets/test.png
or
ux0:/app/ap-id/assets/test.png
i figured, that even a wrong path specified to either of those dirs would throw "unsuported image format" while a completely different, wrong directory would throw "could not open file". Besides that, i'm still a bit worried why it would let me write to "ux0:domis4/log.txt" in safe mode.
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Sat Apr 15, 2017 2:13 pm
by noname120
Strange. I don't have much experience with SDL2, you should probably ask xerpi on
http://webchat.freenode.net/?channels=%23henkaku
By the way, you should change your VITA_TITLEID because "VSDK00013" is already used by a Vita sample.
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Sun Oct 15, 2017 8:48 pm
by nop90
This post is some months old, but I startes coding for the vita only a couple of weeks ago, and I had the same problem. Since no one answered to the problem, reporting the solution could be of help to other developers.
I found that SDL2_Image is compiled without the flags that enable the supported file formats, this maked that lib useless.
Adding that flags (-DLOAD_BMP -DLOAD_GIF -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM -DLOAD_TGA -DLOAD_XCF -DLOAD_XPM -DLOAD_XV -DLOAD_JPG -DLOAD_PNG) and compiling again the lib solved the problem.
Hope this helps.
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Tue Oct 17, 2017 2:36 am
by noname120
Feel free to make a pull request here with modified compilations params:
https://github.com/lourinaldi/SDL_image ... SDL2_image
The change will then make its way to the sdk.
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Tue Oct 17, 2017 10:41 am
by nop90
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Thu Nov 30, 2017 8:54 am
by Red-j
Hi all I have try to use png but with no luck. I have compiled with new library but it doesn't work for me
I have replace the lib.a with the new file.
anyone can explain or show is cmakelist and explaine which includes used in their main.c
I have try to include png.h in my main.c and png flag in cmakelist
Thanks
Best regards
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Thu Nov 30, 2017 9:11 am
by nop90
Please, upload an example of your code somewhere (github , googledrive, or something else) and I'll check it.
Re: C++ SDL2_image IMG_LoadTexture: Unsupported image format
Posted: Thu Nov 30, 2017 9:39 am
by Red-j
Ok bro I will upload in 8 hours, I'm at work

thank you a lot