PDA

View Full Version : a different world/screen coordinate question

12-03-2002, 12:18 PM
Is there a way to "re-scale" the world coordinate system so that, on the plane Z=0, the WCS would map one X or Y unit to one screen pixel?

That is, on a 640x480 screen, screen coordinate ( 0,0 ) would map to WCS ( 0,480 ) and screen coordinate ( 0,1 ) would map to WCS ( 0, 479 ) and SC ( 1, 0 ) would map to WCS ( 1, 480 ), etc...

Do I have to do the translation myself using gluUnproject or something similar?

bakery2k
12-03-2002, 06:29 PM
Use an orthographic projection.
Look up glOrtho.

ae97004
12-03-2002, 08:28 PM
use glUnproject along with your viewport size and you should have the answer to it...

ae97004

12-04-2002, 09:45 AM
Is there a way to accomplish this using the
glPushMatrix(), glPopMatrix() functions?
How would the performance of that approach compare to the other solutions?

nexusone
12-04-2002, 12:35 PM
You can do it this way:

glViewport (0, 0, 640, 640);

glOrtho(0, 640, 640,0 ,-1, 1);

This should give you a equal drawing area for view and openGL world space.

Here is the def for glOrtho

glOrtho( GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble zNear,
GLdouble zFar )

Originally posted by bluephysics@excite.com:
Is there a way to "re-scale" the world coordinate system so that, on the plane Z=0, the WCS would map one X or Y unit to one screen pixel?

That is, on a 640x480 screen, screen coordinate ( 0,0 ) would map to WCS ( 0,480 ) and screen coordinate ( 0,1 ) would map to WCS ( 0, 479 ) and SC ( 1, 0 ) would map to WCS ( 1, 480 ), etc...

Do I have to do the translation myself using gluUnproject or something similar?

12-11-2002, 10:49 PM
Could someone write a complete compilable example using glOrtho that just draws a 10 pixel line?

Thanks
-dufus1097