Closed aqnuep closed 2 months ago
Will it help to bracket these includes and any other write-related code in ktx_wrapper with#if KTX_FEATURE_WRITE?
For some reason I cannot reply on this comment, so replying here: what do you mean by that?
@abasilak, @ViNeek please review this PR. Please pay particular attention to the following:
LIBKTX
to createKtxModule
(and createKtxReadModule
). window.ktx = <module returned from createKtxModule>
so now I have code like var texture = new ktx.ktxTexture
which is feels daft. I'd like to remove the ktx prefix from all the times that currently have it. What do you think? Note that the all the c++ code for the binding is in a ktx
namespace. The extra prefixes really are superfluous in my opinion. I would, if I can figure out how, provide the old names as aliases.ktx
prefixes from the only existing class that had it, ktxTexture
, and from the new classes and have provided an alias from ktxTexture
to texture
.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.
Here is a screenshot of the test for the new features.
Hi @MarkCallow thank you for the great work.
Regarding you comments:
Test page also looks very good.
@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 ktx{,_}
prefixes and _e
suffixes for consistency and to make it easier for people to recall what the JS name will be. Please take a look at 6966f6c.
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_GetLevelSize
function.ktxTexture[12]_Create
const
.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
.createCopy
findKeyValue
getDataSize
getOETF
getPrimaries
getImage
for retrieving an image from the texture. Fixes #288.setImageFromMemory
compressAstc
compressBasis
deflateZstd
deflateZLIB
addKVPairString
andaddKVPairByte
deleteKVPair
setOETF
setPrimaries
writeToMemory
It makes available two bindings. First is a read-only binding,
libktx_read.js
which has the previously available functions plusfindKeyValue
,getDataSize
,getOETF
,getPrimaries
andgetImage
. The second, using the original namelibktx.js
, has functions for creating new KTX texture objects and writing them to files.The JS
ktxTexture
class has been renamedtexture
as typical usage is with an Emscripten module instance name ofktx
andnew ktx.ktxTexture()
looks weird. Newly added classes do not havektx
prefixes.Compared to the Phasmatic bindings it:
compressBasisU
which was bundling calls toktxTexture2_CompressBasisEx
,ktxTexture2_DeflateZstd
,ktxTexture2_WriteToMemory
andktxHashList_addKVPair
. Instead each function now has a binding and can be called by the JS client.createFromBuffer
which was using parameters passed from Javascript to determine the VKFormat and size of the texture then creating it withktxTexture2_Create
and finally loading an image from a passed ArrayBufferView into the texture viaktxTexture_SetImageFromMemory
. Instead aktxCreateInfo
can be initialized in the JS code which can callnew ktxTexture
to create the texture then callsetImageFromMemory
to put the image into the texture object.