Conversation
For some reason I cannot reply on this comment, so replying here: what do you mean by that? |
* Load .png and get data from it. * Display a texture on a rotating cube. * Create div elements
* Make createInfo parameter of ktxTexture{,1,2}_{Create,construct}
constant so other language bindings can make it constant.
* Expose ktxTexture_calcLevelSize and ktxTexture_GetLevelSize. This
became useful when KTX_FACESLICE_WHOLE_LEVEL was added to
ktxTexture*_SetImageFrom* and should have been added then. It is
prompted now by the addition of a getImage function to the JS
binding.
Generate isSrgbFormat to vkformat_check.c.
1815d9b to
15ab4da
Compare
|
@abasilak, @ViNeek please review this PR. Please pay particular attention to the following:
I would like the glTF-Compressor to be updated to use this binding. Is there any room in your existing Khronos contract for that work? Better reply to me privately on this question. |
Modify libktx-read-test.js to use new `texture' name and cleanup.
|
Hi @MarkCallow thank you for the great work. Regarding you comments:
Test page also looks very good. |
Use libktx names with `ktx{,_}` prefix and `_e` suffix removed.
Users will no longer need to remember or lookup the different
name used in the binding.
|
@ViNeek thank you for your review and comments. I have made one final (fingers crossed) change. I have changed the enumerator names to be the same as the libktx names minus the |

This PR has been repurposed from adding the Phasmatic bindings for partial write functionality into adding bindings for nearly the full libktx functionality and a test for all the new functionality.
The PR makes the following minor API changes to libktx:
ktxTexture_GetLevelSizefunction.ktxTexture[12]_Createconst.ktxTexture2_{GetPrimaries_e, SetOETF and SetPrimaries}functions.It adds the following functions to the JS binding while modernizing and greatly improving the binding code:
ktxTexture_Create.createCopyfindKeyValuegetDataSizegetOETFgetPrimariesgetImagefor retrieving an image from the texture. Fixes ktxTexture should expose its data via JS bindings #288.setImageFromMemorycompressAstccompressBasisdeflateZstddeflateZLIBaddKVPairStringandaddKVPairBytedeleteKVPairsetOETFsetPrimarieswriteToMemoryIt makes available two bindings. First is a read-only binding,
libktx_read.jswhich has the previously available functions plusfindKeyValue,getDataSize,getOETF,getPrimariesandgetImage. The second, using the original namelibktx.js, has functions for creating new KTX texture objects and writing them to files.The JS
ktxTextureclass has been renamedtextureas typical usage is with an Emscripten module instance name ofktxandnew ktx.ktxTexture()looks weird. Newly added classes do not havektxprefixes.Compared to the Phasmatic bindings it:
compressBasisUwhich was bundling calls toktxTexture2_CompressBasisEx,ktxTexture2_DeflateZstd,ktxTexture2_WriteToMemoryandktxHashList_addKVPair. Instead each function now has a binding and can be called by the JS client.createFromBufferwhich was using parameters passed from Javascript to determine the VKFormat and size of the texture then creating it withktxTexture2_Createand finally loading an image from a passed ArrayBufferView into the texture viaktxTexture_SetImageFromMemory. Instead aktxCreateInfocan be initialized in the JS code which can callnew ktxTextureto create the texture then callsetImageFromMemoryto put the image into the texture object.