How can I create a KTX2 texture from buffer that is in memory and save it to a file? #554
-
I can't figure out how to use the KTX writer module or just manually create a KTX2 texture. I am looking at the following API reference: https://www.khronos.org/ktx/documentation/libktx/group__writer.html Firstly, I do not have access to ktxTexture *tex = nullptr;
// This function does not exist. Only ktxTexture2_Create exists
// but there are no counterparts for ktxTexture_SetImageFromMemory that
// allows using ktxTexture2
auto res = ktxTexture_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE,
&ktxTexture);
ktxTexture_SetImageFromMemory(
ktxTexture, 1, 1, 1, static_cast<const ktx_uint8_t *>(textureDataLoadedFromSTB),
textureSize);
FILE *file = fopen(fileName.string().c_str(), "wb");
ktxTexture_WriteToStdioStream(ktxTexture, file); What am I missing here? How can I access the writer API? I am using KTX4.0.0 and building it with the following Cmake flags: "KTX_FEATURE_TESTS": "OFF",
"KTX_FEATURE_TOOLS": "OFF",
"KTX_FEATURE_VULKAN": "OFF",
"KTX_FEATURE_KTX1": "OFF",
"KTX_FEATURE_STATIC_LIRBARY": "ON", |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Somehow you have ended up at a very old version of the documentation. ktxWriteKTXF was deprecated a very long time and subsequently removed. Here is the latest version of the page you were looking at. See also the Introduction of the libktx documentation for a good summary of how to do various things with the library. How did you end up at that page? I don't see a link to it on the KTX landing page at www.khronos.org/ktx or any of the pages linked from there. The only link I found points to the documentation I just pointed you to. I'll ask the Khronos Webmaster to update https://www.khronos.org/ktx/documentation. |
Beta Was this translation helpful? Give feedback.
-
@baiwenbo1997 the |
Beta Was this translation helpful? Give feedback.
Somehow you have ended up at a very old version of the documentation. ktxWriteKTXF was deprecated a very long time and subsequently removed. Here is the latest version of the page you were looking at. See also the Introduction of the libktx documentation for a good summary of how to do various things with the library.
How did you end up at that page? I don't see a link to it on the KTX landing page at www.khronos.org/ktx or any of the pages linked from there. The only link I found points to the documentation I just pointed you to.
I'll ask the Khronos Webmaster to update https://www.khronos.org/ktx/documentation.