From 9a66b454560401d47072de7f37a15970b9a25127 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Tue, 12 Nov 2024 23:00:16 +0100 Subject: [PATCH 1/2] Fix JNI function name for getDataSizeUncompressed --- .../java_binding/src/main/cpp/KtxTexture.cpp | 2 +- .../org/khronos/ktx/test/KtxTexture2Test.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/interface/java_binding/src/main/cpp/KtxTexture.cpp b/interface/java_binding/src/main/cpp/KtxTexture.cpp index 0a6028f613..d8faf64a48 100644 --- a/interface/java_binding/src/main/cpp/KtxTexture.cpp +++ b/interface/java_binding/src/main/cpp/KtxTexture.cpp @@ -188,7 +188,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_khronos_ktx_KtxTexture_getDataSize(J return static_cast(ktxTexture_GetDataSize(texture)); } -extern "C" JNIEXPORT jlong JNICALL Java_org_khronos_KTXTexture_getDataSizeUncompressed(JNIEnv *env, jobject thiz) +extern "C" JNIEXPORT jlong JNICALL Java_org_khronos_ktx_KtxTexture_getDataSizeUncompressed(JNIEnv *env, jobject thiz) { ktxTexture *texture = get_ktx_texture(env, thiz); if (texture == NULL) diff --git a/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java b/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java index 2518bc8cbd..1ba1b95bf3 100644 --- a/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java +++ b/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java @@ -599,4 +599,37 @@ public void testSupercompressionZLIB() throws IOException { t.destroy(); } + + @Test + public void testBindings() { + Path testKtxFile = Paths.get("") + .resolve("../../tests/testimages/astc_ldr_4x4_FlightHelmet_baseColor.ktx2") + .toAbsolutePath() + .normalize(); + + KtxTexture2 texture = KtxTexture2.createFromNamedFile(testKtxFile.toString(), + KtxTextureCreateFlagBits.NO_FLAGS); + texture.getOETF(); + texture.getPremultipliedAlpha(); + texture.needsTranscoding(); + texture.getSupercompressionScheme(); + texture.getVkFormat(); + + texture.isArray(); + texture.isCubemap(); + texture.isCompressed(); + texture.getGenerateMipmaps(); + texture.getBaseWidth(); + texture.getBaseHeight(); + texture.getBaseDepth(); + texture.getNumDimensions(); + texture.getNumLevels(); + texture.getNumFaces(); + texture.getDataSize(); + texture.getDataSizeUncompressed(); + texture.getElementSize(); + texture.getRowPitch(0); + texture.getImageSize(0); + } + } From bd199ff2e9630ac71b303b06abee8bccb8ededc4 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Thu, 14 Nov 2024 13:00:20 +0100 Subject: [PATCH 2/2] Added comments to bindings test --- .../java/org/khronos/ktx/test/KtxTexture2Test.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java b/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java index 1ba1b95bf3..0e00b1744c 100644 --- a/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java +++ b/interface/java_binding/src/test/java/org/khronos/ktx/test/KtxTexture2Test.java @@ -607,14 +607,24 @@ public void testBindings() { .toAbsolutePath() .normalize(); + // The purpose of this test is to check the bindings for the 'native' + // functions that only return a value. When the binding for one of + // these functions is not implemented properly, then trying to call + // it will cause an 'UnsatisfiedLinkError'. + // This does not cover all 'native' functions: Some of them can only + // sensibly be called in the context of the other tests. + KtxTexture2 texture = KtxTexture2.createFromNamedFile(testKtxFile.toString(), KtxTextureCreateFlagBits.NO_FLAGS); + + // Native getter methods from the 'KtxTexture2' class texture.getOETF(); texture.getPremultipliedAlpha(); texture.needsTranscoding(); texture.getSupercompressionScheme(); texture.getVkFormat(); + // Native getter methods from the 'KtxTexture' class texture.isArray(); texture.isCubemap(); texture.isCompressed();