Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: a different world/screen coordinate question

  1. #1
    Guest

    a different world/screen coordinate question

    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?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    London, England
    Posts
    163

    Re: a different world/screen coordinate question

    Use an orthographic projection.
    Look up glOrtho.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2002
    Location
    Starkville,Mississippi,USA
    Posts
    19

    Re: a different world/screen coordinate question

    use glUnproject along with your viewport size and you should have the answer to it...

    ae97004
    Dont argue with fools, they bring you down to their level and beat you with experience.

  4. #4
    Guest

    Re: a different world/screen coordinate question

    Is there a way to accomplish this using the
    glPushMatrix(), glPopMatrix() functions?
    How would the performance of that approach compare to the other solutions?

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: a different world/screen coordinate question

    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?


  6. #6
    Guest

    Re: a different world/screen coordinate question

    Could someone write a complete compilable example using glOrtho that just draws a 10 pixel line?

    Thanks
    -dufus1097

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •