How to update opengl modelview matrix with my own 4x4 matrix?

shan picture shan · Feb 1, 2012 · Viewed 11k times · Source

I have 4x4 matrix for object's transformations.

float mat44[16];

But i don't know how to update OpenGL ModelView matrix using my matrix. should i use glTranslatef()/glRotatef() with relavant values from my matrix or should i use glLoadMatrix(),glMultMatrix() ? Pls help. Thanks.

Answer

Mārtiņš Možeiko picture Mārtiņš Možeiko · Feb 1, 2012

If you want to apply your transformation to current transformation already in OpenGL matrix stack, then you should write:

glMultMatrixf(mat44);

But if you want to discard what's currently on top of OpenGL matrix stack and use your own transformation, then you should write:

glLoadMatrixf(mat44);