I have a small project, which was written with LWJGL 2 and wanted now to move to version 3. I changed the main lib without bigger problems. But in small steps. So I first didn't do a change to the Vector and Matrix classes. Instead, in the new project I added the old lwjgl_util.jar. I could render everything as normal. The only loss I had till this point was the input of keyboard and mouse, but this is not a big problem.
The next and crucial step was to delete the extra .jar file again and change all imports to the org.joml.Vector2f, org.joml.Vector2f and org.joml.Matrix4f classes, and the needed changes in my code. Eclipse says there is no more error, and so says the JVM too.
The code runs, if I print vectors or matrices. They all have data as they should.
But instead of the normal world it should render, there is only the clear color for the background (the correct one btw.).
My thinking is, I got no data from Java to the shader and shader multiplies all matrices to zero and I can't see anything.
I found this line on https://github.com/JOML-CI/JOML/wiki/Migrating-from-LWJGL-2 and have an idea that this could may be my problem, but I don't understand exactly what it means:
One important difference is the handling of NIO FloatBuffers when getting values from or writing values into a FloatBuffer. In LWJGL 2 the position of the FloatBuffer will be incremented by load and store operations. In JOML the position will not be changed!
So my question now:
How is the handling of the FloatBuffers with this not changing position be done?
public abstract class ShaderProgram {
private static FloatBuffer matrixBuffer = BufferUtils.createFloatBuffer(16);
...
protected void loadMatrix(int location, Matrix4f matrix) {
matrix.get(matrixBuffer);
matrixBuffer.flip();
GL20.glUniformMatrix4fv(location, false, matrixBuffer);
}
}