-
Notifications
You must be signed in to change notification settings - Fork 103
Migrating from LWJGL 2
This article is for people who are currently using LWJGL 2 and wanting to switch to LWJGL 3. So if you are using LWJGL 2 and especially its "util" jar with the classes in the included vector package, you can migrate easily to JOML.
JOML uses a very similar design compared to LWJGL 2's util vecmath classes. All operations on vectors and matrices come in the two known fashions:
- as instance methods operating on the object itself and changing its value
- as static methods accepting the source object and the destination object which will hold the result
The methods rotate, translate and scale also do post-multiplication of their respective transformations with the current matrix values.
Some operations have different names or do not exist (currently) in JOML, though, and these are listed in the following table:
LWJGL 2 | JOML |
---|---|
setIdentity | identity |
setZero | zero |
load | set |
loadTransposed | N/A |
store | get |
storeTransposed | N/A |
store3f | N/A |
determinant3x3 | N/A |
The matrix operations implemented in the GLU class are part of the Matrix4f in JOML. However, unlike the methods in LWJGL 2, JOML does not interface with OpenGL to multiply the matrices. Instead, JOML post-multiplies the projection and view transformations by the Matrix4f they are invoked on. So, they work just like the other transformation methods rotate(), scale() and translate() in JOML.
Therefore, you need to fill a FloatBuffer and use glLoadMatrixf() if you want to upload the matrix to OpenGL:
Matrix4f m = ...;
FloatBuffer fb = BufferUtils.createFloatBuffer(16);
m.get(fb);
glLoadMatrixf(fb);