04-05-2004, 08:00 PM
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.
04-06-2004, 08:21 AM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.