|
发表于 2009-8-31 21:04:00
|
显示全部楼层
Re:???OPENGL???????????????????
?????OpenGL????
????OpenGL???????????????OpenGL???????????????????
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
winX = (float)x; winY = viewport[3] - (float)y;
glReadPixels((int)winX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
??(x, y)??????(winX, winY, winZ)????????????(posX, posY, posZ)?OpenGL???
???????????????????????glViewport(0, 0, screenWidth, screenHeight)?screenWidth?screenHeight??????????????????????0?0??????????????
??????OpenGL???????????????????????????????????OpenGL??????????winX = (float)x; winY = viewport[3] - (float)y;??????gluUnProject??????????gluUnProject??????????? ???????????????glGetIntegerv???????????????????????????????????????????????????????????????????????????????????????????????????????????glGetIntegerv??????????????
?winx = x ? viewport[0]; winy = screenHeight ? viewport[1] - y; viewport[0] = viewport[1] = 0;
?winx = x; winy = screenHeight ? y;
?????????????????????????????????????????????0?0???????????????glViewport????????????????0?0??????????????????????????????????????????
??????????????????????glUnproject???winx?winy???????? ????????????????
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;
glPushMatrix(); // ?????????????????????????
glScalef(m_srtMatrix[0], m_srtMatrix[1], m_srtMatrix[2]); // ??????????
glRotatef(m_srtMatrix[3], 1.0f, 0.0f, 0.0f);
glRotatef(m_srtMatrix[4], 0.0f, 1.0f, 0.0f);
glRotatef(m_srtMatrix[5], 0.0f, 0.0f, 1.0f);
glTranslatef(m_srtMatrix[6], m_srtMatrix[7], m_srtMatrix[8]);
glGetIntegerv(GL_VIEWPORT, viewport); // ???????????????
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glPopMatrix();
winX = x; winY = screenHeight - y;
glReadPixels((int)winX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); |
|