PDA

View Full Version : glOrtho & glViewport



Cerv36
02-21-2003, 01:34 PM
Hello,
I was hoping someone could tell me what the difference is between glOrtho and glViewport. Things I have read say stuff like "use glOrtho and glViewport for clipping purposes". I now know that the glViewport actually sets what you are part of the screen you can see a picture, but I'm not sure what role glOrtho plays.
For example, if I have a window of size 800 * 500 and want a viewport of 400 * 300, I know that I want: glViewport(0, 0, 400, 300)--maybe adusted to move it around the screen, that's fine. But what do I set glOrtho too?
Thanks,
Bob

HalcyonBlaze
02-21-2003, 02:14 PM
glOrtho is responsible for setting up an orthographic projection. Basically all the planes in the view frustum are orthogonal (perpendicular). Orthographic projection is basically the unit cube scaled. A viewport has nothing really to do with projection. As you said it determines how much of the window OpenGL uses to render to. The other kind of projection is the perspective projection. That has the shape of a frustum. A frustum is basically a pyramid with the pointy part cut off.

- Halcyon

nexusone
02-21-2003, 06:58 PM
This is asked over and over here.

glViewport is the screen or window area in which to render to.

Most people set the vieport to the size of the window, but i can be less. say on a 640 x 480 window, you set the view port to 320 x 240 then only have the window would be rendered to the other half blank. You could use this to create a split screen for a game, render first one sides data then render the second sides data.


glOrtho is the 3D area in which to render from, which form a cube like area. Only things within the cube will be displayed when rendered to the screen.

Cerv36
02-21-2003, 08:50 PM
Thank you very much!!



Originally posted by HalcyonBlaze:
glOrtho is responsible for setting up an orthographic projection. Basically all the planes in the view frustum are orthogonal (perpendicular). Orthographic projection is basically the unit cube scaled. A viewport has nothing really to do with projection. As you said it determines how much of the window OpenGL uses to render to. The other kind of projection is the perspective projection. That has the shape of a frustum. A frustum is basically a pyramid with the pointy part cut off.

- Halcyon