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 3 of 3

Thread: Simple Coordinate System Problem

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2005
    Posts
    26

    Simple Coordinate System Problem

    Hey all.

    I'm trying to learn this crazy coordinate system thing, and a great example that would help me would be to figure out an equation that calculates a point in the viewport from a real-world number.

    For example:

    How do I find the bottom of the screen?
    I know what the window size is, and what the z coord is. How would I translate that to a vector point?

    So far I have this information:

    Window Size: 640x400
    z = -10
    Point I'm trying to get to: 100% (of any direction within the viewport)

    How would I translate that into a floating point vector of the top,right, etc. of the screen?

    Thanks so much for any insight you can supply me!

    j

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Dresden, Sachsen, Germany
    Posts
    205

    Re: Simple Coordinate System Problem

    A)
    you can give gluProject/gluUnproject a try.

    B)
    go all the way back from viewport space to world space by applying the inverse matrices that transform from world to viewport space

    this will be the matrix which is setup by glViewport
    and glOrtho/ glFrustum (depending on the projection)

    and the matrix that goes from perspective coordinates to normalized device coordinates
    but this matrix is incorporated into the projection matrix.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2005
    Posts
    26

    Re: Simple Coordinate System Problem

    Yep.
    That'll pretty much do it!

    Thanks a lot!

    j

Posting Permissions

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