store a matrix created by a function opengl -
i wondering if there easy way store created matrix variable later called glloadmatrix(), point being reset matrix earlier state.
for example:
void reshape(int w, int h){ glviewport(0, 0, (glsizei)w, (glsizei)h); glmatrixmode(gl_projection); glloadidentity(); gluperspective(dist, (glfloat)w / (glfloat)h, 1.0, 20.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(x_shift, y_shift, z_shift); }
the goal being store matrix produced separate variable save current matrix state before multiplying on top of it.
i recommendet stop using gl matrix stack @ all. depracted , has been removed core profile of modern opengl. libraries glm used instead.
however, ask can done matrix stack. use glgetfloatv()
gl_modelview
matrix, gl_projection_matrix
or gl_texture_matrix
query current respective matrix:
glfloat m[16]; glgetfloatv(gl_modelview_matrix, m); // other gl code modifying modelview matrix // ... glmatrixmode(gl_modelview); // make sure restore modelview glloadmatrixf(m); // restore
Comments
Post a Comment