inalogic / pico-pixel-public

Public issue tracker for Pico Pixel http://pixelandpolygon.com
MIT License
7 stars 0 forks source link

Program stops when try to open ktx image #28

Closed SC5Shout closed 5 years ago

SC5Shout commented 5 years ago

I'd like to open "opengl superbible 7th" book example textures http://www.openglsuperbible.com/example-code/ media archive hyperlink, but whatever I open it closes the program or returns unknown format.

jaytaoko commented 5 years ago

Thank you for reporting. There is indeed a problem with ktx images. I am working on a fix...

SC5Shout commented 5 years ago

Lemme know when you fix it.

jaytaoko commented 5 years ago

After a closer look, the ktx files from the source archive were badly written. They missed important information as specified in the KTX file format: https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/

The main issues are:

Without these, the image would load load incorrectly or crash PicoPixel.

I have corrected the archive files and placed a copy here: Modified KTX files

I also recommend you use the version of pico pixel provided here: PicoPixel 0.7.1

Please try it and let me know how it goes.

SC5Shout commented 5 years ago

Now it works almost perfectly, some images are flipped and some do not, guess it is something inside their code, does not matter. How did you look inside the files?

jaytaoko commented 5 years ago

I also noticed the inverted image. I guess this is another issue with how the files were created.

I first thought the issue was with PicoPixel. But then I tested Khronos KTX test images and they were working correctly in PicoPixel.

So then I took a look at the KTX image loader I wrote for PicoPixel and noticed incorrect and bizarre values in some fields. The KTX file format specification was helpful to pinpoint what was missing in the files.

Thank you for reporting!

SC5Shout commented 5 years ago

Thank you for answer

SC5Shout commented 5 years ago

Actually, I've got one more question. How did you fixed files from the book? I mean, I know you had to add imageSize and fix alignment, but that needs to get into texture code somehow. What did you use to get the texture code the way to change it?

jaytaoko commented 5 years ago

I modified my KTX loader such that as it read data from a ktx file, it would write the same data in a new file, add the missing information and correct the data alignment where necessary. It was a quick hack mostly. My personal interest in doing it, is that I now have an additional set of KTX files I can use for tests :)

SC5Shout commented 5 years ago

Oh, nice, thank you.