Unformatted text preview: system
draw_wheel( );
for (j=0; j<5; j++) {
glPushMatrix ();
glRotatef(72.0*j, 0.0, 0.0, 1.0);
glTranslatef (3.0, 0.0, 0.0);
draw_bolt ( );
glPopMatrix ( ); R
RT
RTv Global – Bottom Up
Start Trans Rot Matrix Manipulation – Example
Matrix
Local coordinate system
draw_wheel( );
for (j=0; j<5; j++) {
glPushMatrix ();
glRotatef(72.0*j, 0.0, 0.0, 1.0);
glTranslatef (3.0, 0.0, 0.0);
draw_bolt ( );
glPopMatrix ( ); R
RT
RTv Local – Top Down
Start Rot Trans OpenGL: Conventions
Functions in OpenGL start with gl
gl
Functions
• Most functions just gl (e.g., glColor())
Most
glColor()
• Functions starting with glu are utility functions (e.g.,
Functions
glu
gluLookAt())
gluLookAt()
• Functions starting with glx are for interfacing with the X
Functions
glx
Windows system (e.g., in gfx.c)
Windows OpenGL: Conventions
Function names indicate argument type and number
• Functions ending with f take floats
Functions
• Functions ending with i take ints
Functions
• Functions ending with b take bytes
Functions
• Functions ending with ub take unsigned bytes
Functions
ub
• Functions that end with v take an array.
Functions Examples
• glColor3f() takes 3 floats
• glColor4fv() takes an array of 4 floats
glColor4fv() takes OpenGL: Conventions
Variables written in CAPITAL letters
• Example: GLUT_SINGLE, GLUT_RGB
• usually constants
• use the bitwise or command (x  y) to combine constants OpenGL: Simple Use
Open a window and attach OpenGL to it
Set projection parameters (e.g., field of view)
Setup lighting, if any
Main rendering loop
• Set camera pose with gluLookAt()
Set
– Camera position specified in world coordinates
• Render polygons of model
– Simplest case: vertices of polygons in world coordinates OpenGL: Simple Use
Open a window and attach OpenGL to it
• glutCreateWindow() or FLTK window method OpenGL: Perspective Projection
Set projection parameters (e.g., field of view)
Typically, we use a perspective projection
perspective
• Distant objects appear smaller than near objects
Distant
• Vanishing point at center of screen
• Defined by a view frustum (draw it)
Defined
view Other projections: orthographic, isometric
Other
orthographic isometric Setting up Camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( eyeX, eyeY, eyeZ,
eyeX,
lookX, lookY, lookZ,
upX, upY, upZ);
upX, • eye[XYZ]: camera position in world coordinates • look[XYZ]: a point centered in camera’s view • up[XYZ]: a vector defining the cam...
View
Full Document
 Spring '08
 BLOOMFIELD,A
 Linear Algebra, Matrices, Cartesian Coordinate System, Computer Graphics, triangle

Click to edit the document details