How to convert window co-ordinate to real coordinate

How do I convert pixel co-ordinate like 620 720 to real coordinate like (5,6) which can be used for drawing.
1
2
3
4
double x = x_mouse / (double) WINDOW_WIDTH 
           * (AXIS_X_MAX - AXIS_X_MIN) + AXIS_X_MIN;
double y = (1 - y_mouse / (double) WINDOW_HEIGHT)
           * (AXIS_Y_MAX - AXIS_Y_MIN) + AXIS_Y_MIN;

I tried this but does not work.
1
2
double xc = x /  1366* (1366 - 0) + 0;
double yc = (1 - y /  768) * (-768 - 0) +0 ;

return (0,0) always
It is full screen and my laptop is 1366 * 768
Last edited on
What graphics library are you using?
I am using opengl. However I am working under freeglut
Topic archived. No new replies allowed.