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

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -