Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport);
Gl.glGetDoublev(Gl.GL_PROJECTION_MATRIX, projection);
Gl.glGetDoublev(Gl.GL_MODELVIEW_MATRIX, modelview);
// Из 2d в 3d
Glu.gluUnProject(winX, winY, winZ, modelview, projection,
viewport, out objX, out objY, out objZ);
// Из 3d в 2d
Glu.gluProject(objX, objY, objZ, modelview, projection,
viewport, out winX, out winY, out winZ);
要从 3d 切换到 2d:
将窗口坐标 (x,y) 转换为空间坐标 (x,y,z),反之亦然: