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?
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.
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).
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.