Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. void gl_select(int x, int y)
  2. {
  3. GLint viewport[4];
  4. GLdouble modelview[16];
  5. GLdouble projection[16];
  6. GLfloat winX, winY, winZ;
  7. GLdouble posX, posY, posZ;
  8.  
  9. glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
  10. glGetDoublev(GL_PROJECTION_MATRIX, projection);
  11. glGetIntegerv(GL_VIEWPORT, viewport);
  12.  
  13. winX = (float)x;
  14. winY = (float)viewport[3] - (float)y;
  15. glReadPixels(x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
  16.  
  17. gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
  18.  
  19.  
  20. printf("%f %f %fn", posX, posZ, posY);
  21.  
  22. glutPostRedisplay();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement