Hello.

I took the example code of Writing a KTX file from the documentation overview.

I’m doing cross-platform developement and for now implementing texture creation for OpenGL.

The problem I have is that the function

ktxTexture_Create(&createInfo,
                  KTX_TEXTURE_CREATE_ALLOC_STORAGE,
                  &texture); 

is missing!

I know that versions ktxTexture1_Create(and 2) exist.
But these deliver a ktxTexture1.

When I try to fill the texture later with

 ktxTexture_SetImageFromMemory(texture, level, layer, faceSlice,
                               (const ktx_uint8_t *)data->getContent(), data->getSize());

I need a ktxTexture not a ktxTexture1.

So where is my mistake, how can I correctly create a KTX texture? Or, can I safely cast from ktxTexture1 to ktxTexture? Am I missing some #define?

Since there is no possibility for the library to guess your intention you needed to specify either

ktxTexture1* texture;
ktxTexture1_Create(&createInfo,
                              KTX_TEXTURE_CREATE_ALLOC_STORAGE,
                              &texture1); 

or

   ktxTexture2* texture;
   ktxTexture2_Create(&createInfo,
                              KTX_TEXTURE_CREATE_ALLOC_STORAGE,
                              &texture2); 

After that you can safely cast texture to a ktxTexture when calling ktxTexture_SetImageFromMemory.
The documentation now available on GitHub describes this correctly. I think you must have been looking at old documentation.

Thanks markc.
I know how to do it now!

By the way, I used the documentation at khronos.org/ktx/documentation/libktx/index.html#overview

When possible someone should add a link to the newer GitHub docu and mark that code as deprecated somehow?