DaemonEngine / crunch

Advanced DXTc texture compression and transcoding library and tool, upgraded with Unity improvements, added features, extended system and hardware support, deeply tested.
https://github.com/DaemonEngine/crunch
Other
16 stars 6 forks source link

Replace old stb_image 1.18 with stb_image 2.30 and stb_image_write 1.16 #53

Closed illwieckz closed 5 months ago

illwieckz commented 5 months ago

Replace old stb_image with stb_image 2.30 and stb_image_write 1.16.

Pulled from https://github.com/nothings/stb Commit 013ac3beddff3dbffafd5177e7972067cd2b5083

Fixes #13:

illwieckz commented 5 months ago

To know the modifications that was previously added to the old copy of stb_image, one can compare from the commit before this branch the example1/stb_image.h file with the crnlib/crn_image_utils.cpp file which was just a copy of the same stb_image.h at the time plus some minor changes.

The big difference is that previously, the stb functions were declared in namespace crnlib, it si not anymore.

Other changes is that many minor fixes implemented on crnlib/crn_image_utils.cpp are now lost, but all of them are probably useless and has been likely implemented by upstream in newer stb_image.h. In fact, I managed to produce both Linux, MinGW, macOS and FreeBSD builds without problems.

I guess it means this can introduce a mismatch if crnlib is linked with another software having built another version of stb.

illwieckz commented 5 months ago

The update of stb_image will also help to make the examples less Windows-centric, as the very old stb_image was Windows-centric and the copy in crnlib received fixes before.

illwieckz commented 5 months ago

So, Appveyor says it also builds on MSVC. So it builds everywhere as I verified myself the others.

DolceTriade commented 5 months ago

Did you make any modifications to the upstream file?

illwieckz commented 5 months ago

Except the changes done in stb_image_write: prevent int to overflow before converting it to size_t commit (which are preventing some integers to overflow as reported by CodeQL), the stb files are an unmodified a copy-paste from stb upstream. I plan to submit the patch to stb upstream. My purpose is that future stb updates would just copy-paste the stb upstream.

Edit: I submitted the changes upstream:

illwieckz commented 5 months ago

This reintroduces a sprintf.

They have a pending PR for it:

Edit: I implemented a similar fix.