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

Thread: a question about glViewport

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    17

    a question about glViewport

    In the official reference the description for glViewport() is

    glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let (xnd, ynd) be normalized device coordinates. Then the window coordinates (xw, yw) are computed as follows:

    xw = (xnd + 1) · (width / 2) + x
    yw = (ynd + 1) · (height / 2) + y

    My question is: what does this "normalized device coordinates" mean?

    Thank you in advance for your help.

    Coco

  2. #2
    Senior Member OpenGL Pro sqrt[-1]'s Avatar
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    1,006

    Re: a question about glViewport

    After the perspective matrix the coordinates are in normalized format. Normalized means that they are in the range from -1...1 (with 0,0 being the center of the viewport)

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2003
    Posts
    17

    Re: a question about glViewport

    Thanks. Is there a function to get the normalized device coordinate from a 3D coordinate directly? Or is there a function to get the normalized device coordinate from the screen coordinate?

    Coco

  4. #4
    Junior Member Regular Contributor
    Join Date
    Apr 2004
    Posts
    205

    Re: a question about glViewport

    There is a nice diagram in the opengl spec, section 2.10 "Coordinate transformations", figure 2.6 (on page 32). The normalized coordinates are obtained after the perspective division is applied to the clip coordinates.
    Why the people don't bother to read the spec!?
    There are no funcs of the kind you ask of in opengl itself - it does the transforms internally, for itself only. In the glu supplementary library there are some such helper funcs, or you can just do the transforms you wish by yourself.

Posting Permissions

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