|
|
通过鼠标左键单击获取数据点,然后数据在视中显示,这其间数据的坐标是如何转换的,下面的程序如何解释,特别是画下划线的地方。多谢!
void mouseClick(int button, int state, int x, int y) {
int viewport[4];
int flippedy;
if (state == GLUT_DOWN) {
glGetIntegerv(GL_VIEWPORT, viewport);
flippedy = viewport[3] ? y;
glutPostRedisplay();
}
}
void drawPolyloop(void) {
int i;
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glTranslatef(0.0, 0.0, -10);
glScalef(10.0/viewport[3], 10.0/viewport[3], 10.0/viewport[3]);
glTranslatef(-0.5*viewport[2], -0.5*viewport[3], 0.0);
for (i = 0; i < numVerticies; i++) {
glVertex3f(verticies.x, verticies.y, 0.0);
}
glEnd();
}
void reshape(int w, int h) {
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective (2*atan(0.5)/M_PI*180, (GLfloat) w/(GLfloat) h, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
|
|