I have the following matrix in a text file that brought into a floatbuffer, then stored it into the Matrix4f class in LWJGL. This is the matrix in the text file
1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, -1.0, 0.0, 0.0,
0.0, 0.0, 0.03641997277736664, 1.0
When I add the float buffer to the matrix like this
System.out.println("------------");
for(float x : nums){
System.out.println(x);
}
System.out.println("------------");
Matrix4f matrix4f = new Matrix4f();
FloatBuffer buffer = BufferUtils.createFloatBuffer(nums.length);
buffer.put(nums);
buffer.flip();
matrix4f.load(buffer);
where nums is the float array of values. When I print out the Matrix4f class, it shows
1.0 0.0 0.0 0.0
0.0 0.0 -1.0 0.0
0.0 1.0 0.0 0.036419973
0.0 0.0 0.0 1.0
But if I use the transpose function in the Matrix4f class, it goes back to
1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, -1.0, 0.0, 0.0,
0.0, 0.0, 0.03641997277736664, 1.0
Why does LWJGL change the order I of the values when I create a Matrix4f? The text file holds the matrix in colum major matrix ordering, which is what I need for OpenGl. What format is LWJGL changing the matrix to? Does it make a difference, should I use the transpose function to change it back?
numarray holds the floats in column major order? Because according to the documentation theMatrix4f.loadmethod will load the array in column major order. - Nitramloadfunction ofMatrix4fexpects column major. EDIT: Hey deleting the comment is mean! :P - Nitram