Can someone explain me how the OpenGL coordinate system work ? I mean, I have windows coordiantes when I get WM_LBUTTONDOWN handle message, let’s say X = 100 and Y = 150, why when I use gluUnproject function, I have a smaller value for the X and Y coordinates ?
One reason for your so called “incorrect” values can be that Windows and OpenGL is using different types of window coordinates. In Windows, the Y-axis is going from top to bottom of the window, but in OpenGL, the Y-axis is going from bottom to top. You need to change the Y-coordinate to get OpenGL-coordinates.
I’m making this transformation, but also if I made the y coordinate transformation I have the X,Y OpenGL value smaller then the GDI coordinates, is it normal ?
To do a gluUnproject you need a third coordinate for OpenGL, the z-Buffer value on the x and y windows coordinates. Then gluUnproject gives you the coordinates in the opengl model (3D!). So it’s normal if the values from the screen coordinates differ completely from the 3D-coordinates.
By the way, Is it possibe to have the screen mapped in one metric unit, lets say milimiters ? Someone already made this kind of thing, if yes, can you help me ?
GetDeviceCaps(hDC, HORZSIZE) and
GetDeviceCaps(hDC, VERTSIZE)
gives you the size of your screen in
mm’s. Don’t know, how it works, I think it will work with the monitor settings. Otherwise it couldn’t be determined.