LWJGL Forum

Programming => OpenGL => Topic started by: chris_c on November 24, 2014, 20:46:56

Title: GL Math, Pure Java, JNI, as a lwjgl module or .....?
Post by: chris_c on November 24, 2014, 20:46:56
I've wrapped (the bits I need) of kazmath before now (for a slim GLES wrapper)
I've just recently when trying out lwjgl3 written a mini Mat4 and Vec3 class (pure java)
I've in the past used various 3rd party either stand alone or integrated Math libs

I was just wondering what people thought of the various merits of native or pure math libs and if its something that likely or even worth including as a module of lwjgl3

While native libs ought(!) to be faster, I do wonder if they are so much faster given the time traversing the JNI multiple times and the extra complexity using JNI can sometimes cause.

I'm fairly sure that many people will follow the same road of trying multiple solutions, so I personally could see the value of a lwjgl module

But that just my thoughts, what about yours?
Title: Re: GL Math, Pure Java, JNI, as a lwjgl module or .....?
Post by: Cornix on November 24, 2014, 21:10:01
If it is simple arithmetics then the java code should be almost as fast, if not exactly as fast, as compiled C or C++ code after a little warm-up time. This happens because of the Just-In-Time compiler that will compile the byte code to native code as it is run. At that point it will be as quick as possible.
Of course, by nature, this is not guaranteed. You could also just try it out. Though I would think that you wont gain any advantage from using a native library for that.