Obtaining current ModelView matrix

依然范特西╮ 提交于 2019-12-18 05:48:12

问题


In OpenGL, how do I read the current x/y translation in the modelview matrix? I know that you have to load the current matrix into an array and read the floats from there, but I don't know precisely how to do it.


回答1:


In order to retrieve the current modelview matrix you have to call the glGetFloatv function with GL_MODELVIEW_MATRIX parameter.

GLfloat matrix[16]; 
glGetFloatv (GL_MODELVIEW_MATRIX, matrix); 

From the documentation:

GL_MODELVIEW_MATRIX

params returns sixteen values: the modelview matrix on the top of the modelview matrix stack. Initially this matrix is the identity matrix.




回答2:


Use glGlet

GLfloat matrixf[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrixf);

GLdouble matrixd[16];
glGetDoublev(GL_MODELVIEW_MATRIX, matrixd);

GLint matrixi[16];
glGetIntegerv(GL_MODELVIEW_MATRIX, matrixi);


来源:https://stackoverflow.com/questions/766127/obtaining-current-modelview-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!