{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture04-1

# Lecture04 1

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

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 • right-handed – Hold out your right hand and hold your thumb, index, and Hold middle fingers orthogonal to one another orthogonal – Call your thumb the x-axis, index = y-axis, and middle = Call axis axis – This is the OpenGL coordinate system • The camera defaults to look down negative z-axis Intro to OpenGL So… • X-axis = thumb = 1, 0, 0 • Y-axis = index = 0, 1, 0 • Z-axis = middle = 0, 0, 1 1 0 0 0 1 0 0 0 1 • Camera defaults to look down negative z-axis • Let’s say we want it to look down x-axis Intro to OpenGL Coordinate system transformation so camera Coordinate looks down x-axis looks • If x-axis negative z-axis 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online