LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: mcmacker4 on May 07, 2015, 21:16:27

Title: Setup 3D OpenGL environment in LWJGL3.
Post by: mcmacker4 on May 07, 2015, 21:16:27
Hi,

Some time ago I learned how to create basic 3D stuff in LWJGL2. I want to keep doing so and I would like to upgrade to LWJGL3, but there is one problem:
There is no LWJGL3 specific lwjgl_util.jar and the one that comes with LWJGL2 has an issue with LWJGL3 when using gluPerspective. It uses a function called glMultMatrix and this function was replaced in LWJGL3 by some others like glMultMatrixf and glMultMatrixi (i think).

So how do I create a 3D environment with LWJGL3?

Thanks.
Title: Re: Setup 3D OpenGL environment in LWJGL3.
Post by: Kai on May 08, 2015, 10:10:57
You might consider using a linear algebra library, such as JOML (https://github.com/JOML-CI/Java-OpenGL-Math-Library), which allows you to compute the matrices.
It features functions to compute yourself the perspective (https://github.com/JOML-CI/Java-OpenGL-Math-Library/blob/master/src/com/joml/Matrix4f.java#L1633) and orthogonal (https://github.com/JOML-CI/Java-OpenGL-Math-Library/blob/master/src/com/joml/Matrix4f.java#L1415) projection matrices and view (https://github.com/JOML-CI/Java-OpenGL-Math-Library/blob/master/src/com/joml/Matrix4f.java#L1543) matrices that you know from GLU.
You just need to use glLoadMatrix (http://javadoc.lwjgl.org/org/lwjgl/opengl/GL11.html#glLoadMatrixf(java.nio.ByteBuffer)) in order to upload the computed matrix to the fixed-function pipeline in OpenGL.
One advantage of using a math library like JOML is however that you can also use programmable shaders with uniforms to store the matrix.
So should you decide to leave the fixed-function pipeline behind, you'd still be good to go with JOML.