Opengl 变换顶点后,如何检索顶点的当前位置?
变换顶点后,如何检索顶点的当前位置?我有以下代码 应用变换后,如何获取“模型顶点”的位置 我非常关注屏幕坐标,这样我就可以知道鼠标是否点击了顶点Opengl 变换顶点后,如何检索顶点的当前位置?,opengl,Opengl,变换顶点后,如何检索顶点的当前位置?我有以下代码 应用变换后,如何获取“模型顶点”的位置 我非常关注屏幕坐标,这样我就可以知道鼠标是否点击了顶点 GLU具有函数gluProject()和glunproject(): 如果您的平台没有GLU,您可以随时获取其代码并查看其实现方式。您可以使用。您是否打算将其中一个GLUNProject? glMatrixMode(GL_MODELVIEW); // save model transform matrix GLfloat currentModel
GLU具有函数
gluProject()
和glunproject()
:
如果您的平台没有GLU,您可以随时获取其代码并查看其实现方式。您可以使用。您是否打算将其中一个GLUNProject?
glMatrixMode(GL_MODELVIEW);
// save model transform matrix
GLfloat currentModelMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, currentModelMatrix);
// clear the model transform matrix
glLoadIdentity();
// rotate the x and y axis of the model transform matrix
glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
glRotatef(rotateY, 0.0f, 1.0f, 0.0f);
// reapply the previous transforms
glMultMatrixf(currentModelMatrix);
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// since each vertes is defined in 3D instead of 2D parameter one has been
// upped from 2 to 3 to respect this change.
glVertexPointer(3, GL_FLOAT, 0, modelVertices);
glEnableClientState(GL_VERTEX_ARRAY);