>>106866700
I've used it to test it out, but i'm just a guy learning how to do gamedev, not a big studio.
I only went for ktx because I had managed to load some gltf files, but decoding PNG textures with stbi was taking long enough to be a little annoying.
I agree the interface is kind of unclear at first and there are no good examples to get started. But in the end, all I really needed was just ktxTexture2_CreateFromMemory. I looked at the internals of ktx code and the C function is really just calling a method in the Texture2 C++ class. It seemed kind of insane, but at least the C interface is easy to use.
If you've never done texture compression, there is lots of similar sounding terminology which can be confusing, but actually using it is not that bad. You need your ktx textures to be in one of the BasisU encodings (UASTC (slightly bigger but higher quality) or ETC1s (slightly smaller but much worse quality, pretty much only for mobile)).
GPUs cannot use these formats directly, they're intended to be transcoded to different compressed formats that the GPU can actually use.
I don't know which graphics api you're using, but ASTC is not available on opengl for example. Let's say you want your texture to use BC7 compression, then you'd call ktxTexture2_TranscodeBytes(texture, KTX_TTF_BC7_RGBA, 0). Assuming you have opengl 4 functions you'd do glTextureStorage(tex_id, mipmap_levels, GL_COMPRESSED_RGBA_BPTC_UNORM, width, height) to create the texture.
Note that you can use the toktx tool with --genmipmap. Then ktx gives you all mipmapped textures for all levels (starting with the smallest). You probably shouldn't call glGenerateMipmaps because that is insanely slow on compressed textures. Instead, do something like this:
pixels = decoded_bytes + length;
for level {
pixels -= width * height;
glCompressedTextureSubImage2D(texture, level, 0, 0, width, height), GL_COMPRESSED_RGBA_BPTC_UNORM, level_size, pixels);
width /= 2;
height /= 2;
Comment too long. Click here to view the full text.