Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: resizing viewport

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Hong Kong

    resizing viewport

    if I want to have my displaying object to fit the window no matter how I rotate it, should I be doing calculation depending on the rotation on the obeject and use glViewport or something. I am a newbie on GL, so any help would be appreciate. thx in advance.

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2004

    Re: resizing viewport

    no, you would not use glViewport to make sure everything fit in the window, you would use glFrustum, glPerspective, or glOrtho (only one). The view port is a portion of the window that you want the view volume mapped to.

    You have a screen, a window, a view port, a view plane, and a view volume. Don't worry about the screen, I just included them in that list for completeness.

    You define the dimensions of the view volume (or just end up using the default dimensions) with a call to glFrustum, glPerspective, or glOrtho (or gluLookat or gluOrtho2D). This creates a box that is the parts of the world that are visible on screen. When you want to draw something on screen, you represent it in this view volume. If something does not fit in the view volume, it gets clipped and you either don't see any of it or only some of it.

    The view volume gets squashed down to a view plane, which is the front plane of the view volume. Depending on the size and shape of the view volume, this results in different pictures.

    Next, the edges of the view plane are mapped to the edges of the view port. This does nothing to what is visible in the screen, it only changes the size of what is visible in the screen.

    So, hopefully you can see that changing the view port will not effect how much you can see of the world, only the final size of the picture. If you want to change what is visible in the world, you need to change the view volume, through glPerspective, glFrustum, glOrtho, gluOrtho2d, or gluLookAt.
    capn_midnight | Captain Midnight | deviantArt
    ACM | SIGGRAPH | Generation5

Posting Permissions

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