This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Introduction to
Computer Graphics
CS 445 / 645
Lecture 4
OpenGL Programming Guide OpenGL Announcement
Announcement
• Visit discussion forum to keep up to date
• Red Book is good source for OpenGL Intro to OpenGL
OpenGL operates as an infinite loop
• Put things in the scene (points, colored lines, textured polys)
• Describe the camera (location, orientation, field of view)
• Listen for keyboard events
• Render – draw the scene Intro to OpenGL
OpenGL has a “state”
• There are a lot of ways your OpenGL program can be
There
configured
configured
• The current configuration is stored in OpenGL’s state
• Be aware that OpenGL commands affect the program’s state
Be
rather than redirect its logical execution
rather Intro to OpenGL
OpenGL uses matrices
• Matrix describes camera type
• Matrix describes current configuration of the 3D space
– Explanation… Intro to OpenGL
OpenGL coordinate system
• righthanded
– Hold out your right hand and hold your thumb, index, and
Hold
middle fingers orthogonal to one another
orthogonal
– Call your thumb the xaxis, index = yaxis, and middle =
Call
axis
axis
– This is the OpenGL coordinate system
• The camera defaults to look down negative zaxis Intro to OpenGL
So…
• Xaxis = thumb = 1, 0, 0
• Yaxis = index = 0, 1, 0
• Zaxis = middle = 0, 0, 1 1 0 0
0 1 0 0 0 1 • Camera defaults to look down negative zaxis
• Let’s say we want it to look down xaxis Intro to OpenGL
Coordinate system transformation so camera
Coordinate
looks down xaxis
looks
• If xaxis negative zaxis
If
– x z
–yy
–zx 0 0 1 0 1 0 − 1 0 0 Intro to OpenGL
The a i matrix defines the transformation 1 0 0 a b
0 1 0 × d e 0 0 1 g h c
f i = 0 0 1 0 1 0 − 1 0 0 Why store the transformation matrix and not the final
Why
desired matrix?
desired Intro to OpenGL
The transformation will be applied to many points
• If the following transformation moves the axes
1 0 0 a b
0 1 0 × d e 0 0 1 g h c
f i = 0 0 1 0 1 0 − 1 0 0 • The same transformation moves vertices
The
– Example: (1, 1, 1) (1, 1, 1)
Example: 0 0 1 i i ' 0 1 0 j = j ' − 1 0 0 k k ' Intro to OpenGL
This important matrix is stored as the MODELVIEW matrix
This
MODELVIEW
• The MODELVIEW matrix is so important OpenGL maintains a stack of
The
these matrices
these
• You have control of this stack with the glPushMatrix and glPopMatrix
You
commands
commands
• (The matrix is actually 4x4, but we will study the details to unders...
View
Full
Document
This note was uploaded on 01/23/2012 for the course CS 445 taught by Professor Bloomfield,a during the Spring '08 term at UVA.
 Spring '08
 BLOOMFIELD,A
 Computer Graphics

Click to edit the document details