View Full Version : OpenGL coordinate system
KurtCob
10-04-2000, 01:30 AM
Hello guys,
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 ?
Thank you for the moment
Best regards
Kurt
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.
opengl_y = window_height - windows_y;
KurtCob
10-04-2000, 03:05 AM
Ok Bob,
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 ?
Thank you for the moment
Best regards
Kurt
Kilam Malik
10-04-2000, 03:32 AM
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.
KurtCob
10-04-2000, 03:36 AM
Ok thank you Kilam,
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 ?
Thank you for the moment
Best regards
Kurt
Kilam Malik
10-04-2000, 05:19 AM
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.
KurtCob
10-04-2000, 06:58 AM
Thank you Kilam,
I will try to work in this way.
Best regards
Kurt
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.