SpartanJ / SOIL2

SOIL2 is a tiny C library used primarily for uploading textures into OpenGL.
MIT No Attribution
370 stars 75 forks source link

Add 3Dc/BC5/DXN direct DDS upload #41

Closed stijnherfst closed 4 years ago

stijnherfst commented 4 years ago

This is an implementation for the direct uploading of 3Dc textures. Specifically in this case BC5 which maps to the OpenGL RGTC extension. It checks for the existence of the extension so it should work even on extremely old OpenGL versions.

As a side note I also saw that there is a memcpy that copies the entire texture data which is only necessary for uncompressed loads. I wanted to keep the number of changes small as to facilitate easy merging, but it is something I would like to change as texture uploads are the biggest bottleneck in my application.

Might I ask what C standard you are using, is it C89 or C99? Might it also be useful to set a minimum OpenGL version for the library? Something like OpenGL 3.2 which released 11 years ago or 4.2 from 9 years ago seem like pretty decent targets. Basically any hardware that supports OpenGL and is still in use supports at least OpenGL 3.2 and setting a minimum version can really clean up the codebase. Users requiring older OpenGL versions can always use a release such as 1.20.

SpartanJ commented 4 years ago

Excellent, thanks for your contribution! A couple of things: Most of the changes in this PR are formatting changes, I'm guessing that you are using an auto-formatter. Could you please revert those changes? It makes harder to analyse the PR and I prefer to keep the things as they are. SOIL2 tries to use old C89 for better compatibility with Visual Studio. To ensure the RGTC support please add a texture that can be loaded in the tests as a quick verification. As for the OpenGL support, I prefer to keep it this way. There's no real justification to drop support for older versions since some projects still uses old GL contexts for better compatibility (I personally still do this too). Also it's important to point out that SOIL2 support GL ES and WebGL targets.

stijnherfst commented 4 years ago

I created a Clang format file that I think most closely matches your formatting style. Perhaps you can tweak it more to your liking and add it to the repository. This way everybody can work in their preferred formatting style and there will be no issues with formatting being the primary changes as you can just format the code in the old style automatically after you are done.

clang-format.txt

Rename this file to ".clang-format" and put it in the source folder root. Visual Studio (2017+) and many other editors will automatically detect it.

stijnherfst commented 4 years ago

I added a test image which looks like this: image

SpartanJ commented 4 years ago

Great, it's looking good! As for the clang-format, I actually never defined a format, because I kinda changed the format from the original SOIL and at the moment is a mix of different formats, I should set a format and provide the clang format. I'll check the one you shared. Thanks!