View Full Version : how to match mm with pixels

05-07-2003, 05:49 AM
default unit for opengl coordinate system is pixels. how can I match the unit mm in real world coordinate system with pixels. ie. how many pixels equal 1 mm?

05-07-2003, 11:00 PM
OpenGL has no knowledge about this.
The window manager might know.
For MS Windows check GetDeviceCaps() with HORZSIZE and VERTSIZE, HORZRES and VERTRES.
This only makes sense if the display driver knows which monitor you have attached and supports the function correctly.

05-07-2003, 11:27 PM
Even if Windows does know the screen size and resolution, it's usually possible for the user to use the monitor controls to distort the image (i.e. to stretch the picture to cover all visible space on the monitor).

If you can't accurately determine the pix/mm ratio (which may be different in X and Y) from the windowing system you may have to resort to drawing a square of e.g. 1000x1000 pixels and asking the user to measure it by hand (hold a ruler up to the screen). http://www.opengl.org/discussion_boards/ubb/smile.gif

05-08-2003, 09:52 AM
And this is exactly the kind of thing software like GIMP asks the user the first time it is run. For best results some kind of user callibration is required.