-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix JNI function name for getDataSizeUncompressed
#957
Fix JNI function name for getDataSizeUncompressed
#957
Conversation
@@ -599,4 +599,37 @@ public void testSupercompressionZLIB() throws IOException { | |||
|
|||
t.destroy(); | |||
} | |||
|
|||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment similar to what you wrote in the PR description about this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That certainly makes sense (otherwise, people might wonder what the purpose of the test is).
(An aside: In another context, I automated this kind of test, using some reflection magic - but here, we only have ~20 native
functions, whereas for JCuda, it was about (literally) thousands of native
methods in dozens of classes...)
Thanks @javagl. |
(This builds upon #957, so that should be merged first) This adds bindings for the `ktxTexture_GLUpload` function to the Java interface. There certainly are a few degrees of freedom about how _exactly_ that should be offered. And there is a trade-off between "trying to closely resemble the existing API" and "trying to create a nice API for Java". The main point here being that the function receives three _pointers_ (to `int` values, essentially). And pointers don't exist in Java. A common (although not pretty) way is to emulate these with single-element arrays. So the call currently looks like this: ``` int texture[] = { 0 }; int target[] = { 0 }; int glError[] = { 0 }; int result = ktxTexture.glUpload(texture, target, glError); ``` This will fill the given arrays with the values that are returned from the native layer, accordingly. Proper testing may be difficult. The basic call conditions are checked in a unit test. But beyond that, really _using_ the function will require an OpenGL context to be current, so that 1. requires an OpenGL binding for the test, and 2. can hardly happen during the standard test runs. --- I tried it out in a _very_ basic experiment. This experiment currently used https://www.lwjgl.org/ , but I'll probably also try it with https://jogamp.org/ . Given that LWJGL is the library behind https://libgdx.com/ and https://jmonkeyengine.org/ , that's likely to be a primary goal. The result of that experiment is shown here... ![Khronos KTX in Java](https://github.com/user-attachments/assets/7c86d565-5fdf-4f31-a20c-f6616c2c99ed) ... and I frankly couldn't care less that it's upside down. It works 🙃
A small fix for the JNI bindings:
The function signature for
getDataSizeUncompressed
was given asJava_org_khronos_KTXTexture_getDataSizeUncompressed
but must beJava_org_khronos_ktx_KtxTexture_getDataSizeUncompressed
(matching the full package- and class name)Currently, calling this function would result in a
java.lang.UnsatisfiedLinkError: org.khronos.ktx.KtxTexture.getDataSizeUncompressed()J
I also added a test that might look useless at the first glance: It just creates a texture, and calls all the
native
"getter" functions on that (without any assertion). The point of that test is that it would have prevented this kind of error...