Search code examples
opengllwjgl

How can I get my current OpenGL transformation matrix in a Matrix4f?


For the purposes of lighting, I need to get the current transformation matrix.

For example, Matrix4f transMatrix = Get_OpenGL_Transformation_Matrix

There are various answers on forums, but these either don't work or have people disagreeing with each other.


Solution

  • Simple.

    float[16] transMatrix;
    glGetFloatv(GL_MODELVIEW_MATRIX, transMatrix);