- matrix projection in openGL
- set up clipping
- use glOrtho, glFrustum and gluPerspective

computer viewing
- we've position camera and models
- we're going to look at selecting a lens and setting hte clipping volume

- switch to glMatrixMode(GL_PROJECTION)
- probaly want to clear the last lens with glLoadIdentity()

- initially camera is located at the origin and points in -z
- default projection is orthogonal
- default view volume is a cube with sides of length 2 centered at the origin
- anything outside the view cube will be “clipped”

glOrtho(xmin, xmax, ymin, ymax, near, far)
(near and far are measured from CAMERA)
- 2d vertex commands place all vertices on the plane z=0

for 2d we can use
glOrtho(left,right,bottom,top)
- kind of like making a volume with an infinitely thin z width, so u end up with just a plane


perspective mode:
- glFrustum(xmin,xmax,ymin,ymax,near,far)
- x and y min and max are all defined on the near plane

2023/10/25 - 11:42
Field of view
FOV must be in the range of 0-180
- a bigger FOv exaggerates the perspective effect
- FOV and aspect ratio are enough to define the pyramid, but we also need to define the near and far clipping planes

Diff between ortho and perspective
-
gluPerspective(fovy, aspect, near, far)
gluPerspective(90, (float)windowWidth/(float)windowHeight, 0.120)
//that goes in initializeGL



Resize:
- we have to adjust the viewport
-
void myResize(int newWidth, int newHeight){
    windowWidth = newWidth
    windowHeight = newHeight
    
    glViewport(0,0,windowWidth, windowHeight)
    
    glMatrixMode(GL_PROJECTINO)
    
    glLoadIdentity()
    
    gluPerspective(45, (float)windowWidth/(float)windowHeight, 120)
    
    glMatrixMode(GL_MODELvIEW)

}


Summary
- you can still position and orient the camera with gluLookAt
- caution for gluPerspecive:
→ never use near clipping plane of 0

Index