Like this question states - I want to convert a click (2D) into coordinates relating to the rendering on the screen. I have the function glutMouseFunc
bound to my function (below) but can not make sense of the x and y that are passed in - they seem to be relating to distance in pixels from the top left corner.
I would like to know how to convert the x and y to world coordinates :)
void mouse(int button, int state, int x, int y) {
switch(button) {
case GLUT_LEFT_BUTTON:
printf(" LEFT ");
if (state == GLUT_DOWN) {
printf("DOWN\n");
printf("(%d, %d)\n", x, y);
}
else
if (state == GLUT_UP) {
printf("UP\n");
}
break;
default:
break;
}
fflush(stdout); // Force output to stdout
}