Load the current Matrix

I can update the current Matrix using an array with the function:

glLoadMatrixf(myArray);

But how can I do the inverse?
I mean how can I load the current Matrix in a array to view / edit it?

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

Reference: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glGet.xml

While mhagain’s answer is technically accurate, an arguably-better answer is “don’t do that”.

If you need to access the matrix’ contents from client code, just keep a copy of the matrix in client memory. That means using e.g. GLM to construct the matrix rather than the legacy matrix operations (glRotate, glTranslate, etc). This is a large part of the reason why those functions have been removed from later versions of OpenGL.

Note that using glGet* can cause a pipeline stall, resulting in a significant performance hit. Ideally, it shouldn’t be used outside of initialisation code.

Thank you people, my problem is solved.

It should be added however that because the legacy matrix stack is most likely going to be implemented in software, this particular glGet probably won’t involve a round trip to the GPU and the associated pipeline stall. So yes, glGet calls for current state are in the general case a bad idea, but special case exceptions may exist.