cl-ktx2
2026-01-01
An implementation of the Khronos KTX Version 2 image file format
Upstream URL
Author
Yukari Hafner <shinmera@tymoon.eu>
Maintainer
Yukari Hafner <shinmera@tymoon.eu>
License
zlib
## About cl-ktx2
This is an implementation of the ''Khronos KTX2''(https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html) image file format.
## How To
Load the cl-ktx2 library, and invoke ``read-file`` to read a file from any of the supported ''binary-structures''(https://shinmera.github.io/binary-structures) backends.
The returned structure can be easily accessed. Since the image data is already pre-packed for upload to the GPU, you should be able to just iterate over the ``level-images`` and upload via ``gl-tex-image-2d`` etc.
The documentation on some of the fields, especially when dealing with the data format descriptors, is a bit sparse in this library. This is because these concepts are very complicated, and I'd just be repeating what the Khronos specifications say in other words, so please instead refer to the ''KTX2 Specification''(https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html) and the ''Khronos Data Format Specification''(https://registry.khronos.org/DataFormat/specs/1.4/dataformat.1.4.html) for expanded descriptions on the various fields and data bits.
Note that this library does currently not implement any compression or encoding schemes that the format can contain. As such it is up to you to ensure that the data is interpreted and decoded in the correct way. Cl-ktx2 will simply hand you an opaque octet vector of the data. The same goes for creating files. If you want to create compressed image data, you will likely want to rely on tools like Khronos' own ''ktx-software''(https://github.com/KhronosGroup/KTX-Software), or ''Kram''(https://github.com/alecazam/kram) instead.
If you really want to use a pure Lisp workflow, please contribute the encoding and decoding algorithms :)