100% found this document useful (1 vote)
133 views24 pages

Graphics Slides 06

This document discusses representing planar polygons in computer graphics using OpenGL and GLUT. It introduces planar polygons and polyhedra, data structures for representing them, and provides an overview of OpenGL, related APIs, and how to set up a basic interactive graphics program using GLUT callbacks.

Uploaded by

api-3738981
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
133 views24 pages

Graphics Slides 06

This document discusses representing planar polygons in computer graphics using OpenGL and GLUT. It introduces planar polygons and polyhedra, data structures for representing them, and provides an overview of OpenGL, related APIs, and how to set up a basic interactive graphics program using GLUT callbacks.

Uploaded by

api-3738981
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Interactive Computer Graphics Planar Polyhedra

• These are three dimensional objects whose faces are


• Lecture 6: all planar polygons often called facets.

Polygon Rendering and OpenGL

Graphics Lecture 6: Slide 1 Graphics Lecture 6: Slide 2

Representing Planar Polygons

• In order to represent planar polygons in the computer


we will require a mixture of numerical and
topological data.

• Numerical Data
- Actual coordinates of vertices, etc.

• Topological Data
- Details of what is connected to what, etc.

Graphics Lecture 6: Slide 3 Graphics Lecture 6: Slide 4

1
Data Structures Data Structures

n n type0
• Static Data Structure: x1, y1, z1 p1 offset0
- The point data is stored in arrays p2 type1
p3 offset1
- The topological data are arrays of array indices

• Dynamic Data Structure n


- The topological data is implied by the data structure p1
p2 typen
xn, yn, zn p3 offsetn

Point array Cell array Cell types

Graphics Lecture 6: Slide 5 Graphics Lecture 6: Slide 6

Overview

• General OpenGL Introduction


• Rendering Primitives
• Rendering Modes
• Lighting
• Texture Mapping
• Additional Rendering Attributes
• Imaging

Graphics Lecture 6: Slide 7 Graphics Lecture 6: Slide 8

2
Aims OpenGL and GLUT Overview

• Demonstrate enough OpenGL to write an interactive • What is OpenGL & what can it do for me?
graphics program with • OpenGL in windowing systems
- custom modeled 3D objects or imagery • Why GLUT
- lighting
• A GLUT program template
- texture mapping
• Introduce advanced topics for future investigation

Graphics Lecture 6: Slide 9 Graphics Lecture 6: Slide 10

What Is OpenGL? OpenGL Architecture

• Graphics rendering API


- high-quality color images composed of geometric and Per Vertex
Polynomial Operations &
image primitives Evaluator Primitive
Assembly
- window system independent
- operating system independent
Display Per Fragment Frame
CPU List Rasterization
Operations Buffer

Texture
Memory
Pixel
Operations

Graphics Lecture 6: Slide 11 Graphics Lecture 6: Slide 12

3
OpenGL as a Renderer Related APIs

• Geometric primitives • AGL, GLX, WGL


- points, lines and polygons - glue between OpenGL and windowing systems
• Image Primitives • GLU (OpenGL Utility Library)
- images and bitmaps - part of OpenGL
- separate pipeline for images and geometry - NURBS, tessellators, quadric shapes, etc.
• linked through texture mapping • GLUT (OpenGL Utility Toolkit)
• Rendering depends on state - portable windowing API
- colors, materials, light sources, etc. - not officially part of OpenGL

Graphics Lecture 6: Slide 13 Graphics Lecture 6: Slide 14

OpenGL and Related APIs Preliminaries

• Headers Files
#include <GL/gl.h>
application program
#include <GL/glu.h>
#include <GL/glut.h>
OpenGL Motif
widget or similar GLUT • Libraries
GLX, AGL
or WGL GLU • Enumerated Types
- OpenGL defines numerous types for compatibility
X, Win32, Mac O/S GL
–GLfloat, GLint, GLenum, etc.

software and/or hardware

Graphics Lecture 6: Slide 15 Graphics Lecture 6: Slide 16

4
GLUT Basics Sample Program

• Application Structure void main( int argc, char** argv )


{
- Configure and open window int mode = GLUT_RGB|GLUT_DOUBLE;
- Initialize OpenGL state glutInitDisplayMode( mode );
glutCreateWindow( argv[0] );
- Register input callback functions
init();
• render
glutDisplayFunc( display );
• resize
glutReshapeFunc( resize );
• input: keyboard, mouse, etc. glutKeyboardFunc( key );
- Enter event processing loop glutIdleFunc( idle );
glutMainLoop();
}

Graphics Lecture 6: Slide 17 Graphics Lecture 6: Slide 18

OpenGL Initialization GLUT Callback Functions

• Set up whatever state you’re going to use • Routine to call when something happens
- window resize or redraw
void init( void ) - user input
{
glClearColor( 0.0, 0.0, 0.0, 1.0 ); - animation
glClearDepth( 1.0 );
• “Register” callbacks with GLUT
glEnable( GL_LIGHT0 );
glEnable( GL_LIGHTING );
glEnable( GL_DEPTH_TEST ); glutDisplayFunc( display );
} glutIdleFunc( idle );
glutKeyboardFunc( keyboard );

Graphics Lecture 6: Slide 19 Graphics Lecture 6: Slide 20

5
Rendering Callback Idle Callbacks

• Do all of your drawing here • Use for animation and continuous update

glutDisplayFunc( display ); glutIdleFunc( idle );

void display( void ) void idle( void )


{ {
glClear( GL_COLOR_BUFFER_BIT );
glBegin( GL_TRIANGLE_STRIP ); t += dt;
glVertex3fv( v[0] ); glutPostRedisplay();
glVertex3fv( v[1] ); }
glVertex3fv( v[2] );
glVertex3fv( v[3] );
glEnd();
glutSwapBuffers();
}

Graphics Lecture 6: Slide 21 Graphics Lecture 6: Slide 22

User Input Callbacks Elementary Rendering

• Process user input • Geometric Primitives


• Managing OpenGL State
glutKeyboardFunc( keyboard );
• OpenGL Buffers
void keyboard( char key, int x, int y )
{
switch( key ) {
case ‘q’ : case ‘Q’ :
exit( EXIT_SUCCESS );
break;
case ‘r’ : case ‘R’ :
rotate = GL_TRUE;
break;
}
}

Graphics Lecture 6: Slide 23 Graphics Lecture 6: Slide 24

6
OpenGL Geometric Primitives Simple Example
void drawRhombus( GLfloat color[] )
{
glBegin( GL_QUADS );
GL_LINES glColor3fv( color );
GL_POLYGON
GL_LINE_STRIP GL_LINE_LOOP glVertex2f( 0.0, 0.0 );
GL_POINTS
glVertex2f( 1.0, 0.0 );
glVertex2f( 1.5, 1.118 );
glVertex2f( 0.5, 1.118 );
GL_TRIANGLES glEnd();
}
GL_QUADS
GL_QUAD_STRIP
GL_TRIANGLE_STRIP GL_TRIANGLE_FAN

Graphics Lecture 6: Slide 25 Graphics Lecture 6: Slide 26

OpenGL Command Formats Specifying Geometric Primitives

• Primitives are specified using


glVertex3fv( v ) glBegin( primType );
glEnd();
- primType determines how vertices are combined

GLfloat red, greed, blue;


Number of Data Type Vector Glfloat coords[3];
components b - byte omit “v” for glBegin( primType );
ub - unsigned byte
2 - (x,y)
s - short
scalar form for ( i = 0; i < nVerts; ++i ) {
3 - (x,y,z)
us - unsigned short
glColor3f( red, green, blue );
4 - (x,y,z,w)
i - int glVertex2f( x, y ) glVertex3fv( coords );
ui - unsigned int }
f - float glEnd();
d - double

Graphics Lecture 6: Slide 27 Graphics Lecture 6: Slide 28

7
Shapes Tutorial Controlling Rendering Appearance

• From Wireframe to Texture Mapped

Graphics Lecture 6: Slide 29 Graphics Lecture 6: Slide 30

OpenGL’s State Machine Manipulating OpenGL State

• All rendering attributes are encapsulated in the • Appearance is controlled by current state
OpenGL State for each ( primitive to render ) {
- rendering styles update OpenGL state
render primitive
- shading }
- lighting
• Manipulating vertex attributes is most common way to
- texture mapping manipulate state

glColor*()
glIndex*()
glNormal*()
glTexCoord*()

Graphics Lecture 6: Slide 31 Graphics Lecture 6: Slide 32

8
Controlling current state Transformations in OpenGL

• Setting State • Modeling


glPointSize( size );
• Viewing
glLineStipple( repeat, pattern );
glShadeModel( GL_SMOOTH );
- orient camera
- projection
• Enabling Features
glEnable( GL_LIGHTING ); • Animation
glDisable( GL_TEXTURE_2D ); • Map to screen

Graphics Lecture 6: Slide 33 Graphics Lecture 6: Slide 34

Camera Analogy Camera Analogy and Transformations

• 3D is just like taking a photograph (lots of • Projection transformations


photographs!) - adjust the lens of the camera
• Viewing transformations
- tripod–define position and orientation of the viewing
viewing volume in the world
volume
• Modeling transformations
- moving the model
camera
• Viewport transformations
- enlarge or reduce the physical photograph
tripod model

Graphics Lecture 6: Slide 35 Graphics Lecture 6: Slide 36

9
Coordinate Systems and Transformations Affine Transformations

• Steps in Forming an Image • Want transformations which preserve geometry


- specify geometry (world coordinates) - lines, polygons, quadrics
- specify camera (camera coordinates) • Affine = line preserving
- project (window coordinates) - Rotation, translation, scaling
- map to viewport (screen coordinates) - Projection
• Each step uses transformations - Concatenation (composition)
• Every transformation is equivalent to a change in
coordinate systems (frames)

Graphics Lecture 6: Slide 37 Graphics Lecture 6: Slide 38

Homogeneous Coordinates 3D Transformations


- each vertex is a column vector • A vertex is transformed by 4 x 4 matrices
- all affine operations are matrix multiplications
- all matrices are stored column-major in OpenGL
- matrices are always post-multiplied
- product of matrix and vector is

- w is usually 1.0
- all operations are matrix multiplications
- directions (directed line segments) can be represented with w =
0.0

Graphics Lecture 6: Slide 39 Graphics Lecture 6: Slide 40

10
Transformation
Specifying Transformations Poly.
Per
Vertex

Pipeline CPU DL
Texture
Raster Frag FB

• Programmer has two styles of specifying


Pixel

transformations
object eye clip normalized window
- specify matrices (glLoadMatrix, glMultMatrix) device
- specify operation (glRotate, glOrtho) v
e
• Prior to rendering, view, locate, and orient: r Modelview Projection Perspective Viewport
t
- eye/camera position e Matrix Matrix Division Transform
x
- 3D geometry
Modelview Projection
• Manage the matrices • other calculations here
- material  color
- including matrix stack Modelview - shade model (flat)
- polygon rendering mode
• Combine (composite) transformations  - polygon culling
 - clipping

Graphics Lecture 6: Slide 41 Graphics Lecture 6: Slide 42

Matrix Operations Projection Transformation

• Specify Current Matrix Stack • Shape of viewing frustum


glMatrixMode( GL_MODELVIEW or GL_PROJECTION )
• Perspective projection
• Other Matrix or Stack Operations gluPerspective( fovy, aspect, zNear, zFar )
glLoadIdentity() glFrustum( left, right, bottom, top, zNear, zFar )
glPushMatrix()
glPopMatrix() • Orthographic parallel projection
• Viewport glOrtho( left, right, bottom, top, zNear, zFar )
gluOrtho2D( left, right, bottom, top )
- usually same as window size
- viewport aspect ratio should be same as projection - calls glOrtho with z values near zero
transformation or resulting image may be distorted • Typical use (orthographic projection)
glViewport( x, y, width, height ) glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( left, right, bottom, top, zNear, zFar );

Graphics Lecture 6: Slide 43 Graphics Lecture 6: Slide 44

11
Viewing Transformations Projection Tutorial

• Position the camera/eye in the scene


- place the tripod down; aim camera
tripod
• To “fly through” a scene
- change viewing transformation and
redraw scene
• gluLookAt(eyex, eyey, eyez,
aimx, aimy, aimz,
upx, upy, upz )
- up vector determines unique orientation
- careful of degenerate positions

Graphics Lecture 6: Slide 45 Graphics Lecture 6: Slide 46

Modeling Transformations Transformation Tutorial

• Moving camera is equivalent to moving every object in


the world towards a stationary camera
• Move object
glTranslate{fd}( x, y, z )
• Rotate object around arbitrary axis
glRotate{fd}( angle, x, y, z )
- angle is in degrees
• Dilate (stretch or shrink) or mirror object
glScale{fd}( x, y, z )

Graphics Lecture 6: Slide 47 Graphics Lecture 6: Slide 48

12
Projection is left handed Common Transformation Usage

• Projection transformations (gluPerspective, • 3 examples of resize() routine


glOrtho) are left handed - restate projection & viewing transformations
- think of zNear and zFar as distance from view point • Usually called when window resized
• Everything else is right handed, including the • Registered as callback for glutReshapeFunc()
vertexes to be rendered

y
y z+
left handed right handed
x
x
z+

Graphics Lecture 6: Slide 49 Graphics Lecture 6: Slide 50

resize(): Perspective & LookAt resize(): Perspective & Translate


void resize( int w, int h )
{ • Same effect as previous LookAt
glViewport( 0, 0, (GLsizei) w, (GLsizei) h );
glMatrixMode( GL_PROJECTION ); void resize( int w, int h )
glLoadIdentity(); {
gluPerspective( 65.0, (GLfloat) w / h, glViewport( 0, 0, (GLsizei) w, (GLsizei) h );
1.0, 100.0 ); glMatrixMode( GL_PROJECTION );
glMatrixMode( GL_MODELVIEW ); glLoadIdentity();
glLoadIdentity(); gluPerspective( 65.0, (GLfloat) w/h,
gluLookAt( 0.0, 0.0, 5.0, 1.0, 100.0 );
0.0, 0.0, 0.0, glMatrixMode( GL_MODELVIEW );
0.0, 1.0, 0.0 ); glLoadIdentity();
} glTranslatef( 0.0, 0.0, -5.0 );
}

Graphics Lecture 6: Slide 51

13
resize(): Ortho (part 1) resize(): Ortho (part 2)

void resize( int width, int height ) if ( aspect < 1.0 ) {


{ left /= aspect;
GLdouble aspect = (GLdouble) width / height; right /= aspect;
GLdouble left = -2.5, right = 2.5; } else {
GLdouble bottom = -2.5, top = 2.5; bottom *= aspect;
glViewport( 0, 0, (GLsizei) w, (GLsizei) h ); top *= aspect;
glMatrixMode( GL_PROJECTION ); }
glLoadIdentity(); glOrtho( left, right, bottom, top, near, far );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
… continued …
}

Graphics Lecture 6: Slide 53 Graphics Lecture 6: Slide 54

Double
Compositing Modeling Transformations Poly.
Per
Vertex

Buffering CPU DL
Texture
Raster Frag FB

Pixel
• Problem 1: hierarchical objects
- one position depends upon a previous position
- robot arm or hand; sub-assemblies
• Solution 1: moving local coordinate system
- modeling transformations move coordinate system
- post-multiply column-major matrices 1
2
1
2
4 4
- OpenGL post-multiplies matrices Front 8
16
8
16
Back
Buffer Buffer

Display

Graphics Lecture 6: Slide 55 Graphics Lecture 6: Slide 56

14
Depth Buffering and
Animation Using Double Buffering
Hidden Surface Removal
• Request a double buffered color buffer
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
• Clear color buffer
glClear( GL_COLOR_BUFFER_BIT );
• Render scene
• Request swap of front and back buffers 1
2
1
2
4 4
glutSwapBuffers(); Color 8 8 Depth
16 16
Buffer Buffer
• Repeat steps 2 - 4 for animation

Display

Graphics Lecture 6: Slide 57 Graphics Lecture 6: Slide 58

Depth Buffering Using OpenGL An Updated Program Template

• Request a depth buffer void main( int argc, char** argv )


glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | {
GLUT_DEPTH ); glutInit( &argc, argv );
• Enable depth buffering glutInitDisplayMode( GLUT_RGB |
glEnable( GL_DEPTH_TEST ); GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow( “Tetrahedron” );
• Clear color and depth buffers init();
glClear( GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT ); glutIdleFunc( idle );
glutDisplayFunc( display );
• Render scene glutMainLoop();
• Swap color buffers }

Graphics Lecture 6: Slide 59 Graphics Lecture 6: Slide 60

15
An Updated Program Template (cont.) An Updated Program Template (cont.)
void drawScene( void )
void init( void ) {
{ GLfloat vertices[] = { … };
glClearColor( 0.0, 0.0, 1.0, 1.0 ); GLfloat colors[] = { … };
} glClear( GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT );
glBegin( GL_TRIANGLE_STRIP );
void idle( void )
{ /* calls to glColor*() and glVertex*() */
glutPostRedisplay();
} glEnd();
glutSwapBuffers();
}

Graphics Lecture 6: Slide 61 Graphics Lecture 6: Slide 62

Texture Poly.
Per
Vertex Texture Mapping
Mapping CPU DL
Texture
Raster Frag FB

Pixel

y
• Apply a 1D, 2D, or 3D image to geometric
primitives
z x
• Uses of Texturing geometry screen
- simulating materials
- reducing geometric complexity
- image warping t
image
- reflections

s
Graphics Lecture 6: Slide 63 Graphics Lecture 6: Slide 64

16
Texture Mapping and the OpenGL Pipeline Texture Example

• Images and geometry flow through separate pipelines • The texture (below) is a
that join at the rasterizer 256 x 256 image that has been
- “complex” textures do not affect geometric complexity mapped to a rectangular
polygon which is viewed in
perspective
vertices geometry pipeline
rasterizer
image pixel pipeline

Graphics Lecture 6: Slide 65 Graphics Lecture 6: Slide 66

Applying Textures I Applying Textures II

• Three steps • specify textures in texture objects


 specify texture • set texture filter
• read or generate image • set texture function
• assign to texture
• set texture wrap mode
 assign texture coordinates to vertices
• set optional perspective correction hint
 specify texture parameters
• wrapping, filtering • bind texture object
• enable texturing
• supply texture coordinates for vertex
- coordinates can also be generated

Graphics Lecture 6: Slide 67 Graphics Lecture 6: Slide 68

17
Texture Objects Texture Objects (cont.)

• Like display lists for texture images • Create texture objects with texture data and state
- one image per texture object glBindTexture( target, id );
- may be shared by several graphics contexts • Bind textures before using
• Generate texture names glBindTexture( target, id );
glGenTextures( n, *texIds );

Graphics Lecture 6: Slide 69 Graphics Lecture 6: Slide 70

Specify Texture Poly.


Per Mapping a Poly.
Per
Vertex Vertex

Image CPU DL
Texture
Raster Frag FB Texture CPU DL
Texture
Raster Frag FB

Pixel Pixel

• Based on parametric texture coordinates


• Define a texture image from an array of • glTexCoord*() specified at each vertex
texels in CPU memory
Texture Space Object Space
glTexImage2D( target, level, components, t
w, h, border, format, type, *texels ); 1, 1 (s, t) = (0.2, 0.8)
0, 1 A
- dimensions of image must be powers of 2 a

• Texel colors are processed by pixel pipeline


c (0.4, 0.2)
- pixel scales, biases and lookups can be b
done B C
0, 0 1, 0 s (0.8, 0.4)
Graphics Lecture 6: Slide 71 Graphics Lecture 6: Slide 72

18
Tutorial: Texture Texture Application Methods

• Filter Modes
- minification or magnification
- special mipmap minification filters
• Wrap Modes
- clamping or repeating
• Texture Functions
- how to mix primitive’s color with texture’s color
• blend, modulate or replace texels

Graphics Lecture 6: Slide 73 Graphics Lecture 6: Slide 74

Filter Modes Mipmapped Textures

Example: • Mipmap allows for prefiltered texture maps of decreasing


glTexParameteri( target, type, mode ); resolutions
• Lessens interpolation errors for smaller textured objects
• Declare mipmap level during texture definition
glTexImage*D( GL_TEXTURE_*D, level, … )
• GLU mipmap builder routines
gluBuild*DMipmaps( … )
• OpenGL 1.2 introduces advanced LOD controls
Texture Polygon Texture Polygon
Magnification Minification

Graphics Lecture 6: Slide 75 Graphics Lecture 6: Slide 76

19
Wrapping Mode Texture Functions

• Example: • Controls how texture is applied


glTexParameteri( GL_TEXTURE_2D, glTexEnv{fi}[v]( GL_TEXTURE_ENV, prop,
GL_TEXTURE_WRAP_S, GL_CLAMP ) param )
glTexParameteri( GL_TEXTURE_2D,
GL_TEXTURE_WRAP_T, GL_REPEAT ) • GL_TEXTURE_ENV_MODE modes
- GL_MODULATE
- GL_BLEND
- GL_REPLACE
t
• Set blend color with GL_TEXTURE_ENV_COLOR
s
GL_REPEAT GL_CLAMP
texture
wrapping wrapping
Graphics Lecture 6: Slide 77 Graphics Lecture 6: Slide 78

Is There Room for a Texture? Lighting Principles

• Query largest dimension of texture image • Lighting simulates how objects reflect light
- typically largest square texture - material composition of object
- doesn’t consider internal format size
- light’s color and position
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &size )
- global lighting parameters
• Texture proxy • ambient light
- will memory accommodate requested texture size? • two sided lighting
- no image specified; placeholder
- available in both color index
- if texture won’t fit, texture state variables set to 0
and RGBA mode
• doesn’t know about other textures
• only considers whether this one texture will fit all of memory

Graphics Lecture 6: Slide 79 Graphics Lecture 6: Slide 80

20
Surface
How OpenGL Simulates Lights Poly.
Per
Vertex

Normals CPU DL
Texture
Raster Frag FB

Pixel
• Phong lighting model
- Computed at vertices
• Normals define how a surface reflects light
• Lighting contributors glNormal3f( x, y, z )
- Surface material properties
- Current normal is used to compute vertex’s color
- Light properties
- Use unit normals for proper lighting
- Lighting model properties • scaling affects a normal’s length
glEnable( GL_NORMALIZE )
or
glEnable( GL_RESCALE_NORMAL )

Graphics Lecture 6: Slide 81 Graphics Lecture 6: Slide 82

Material Properties Light Properties

• Define the surface properties of a primitive glLightfv( light, property, value );


glMaterialfv( face, property, value ); - light specifies which light
- separate materials for front and back • multiple lights, starting with GL_LIGHT0
glGetIntegerv( GL_MAX_LIGHTS, &n );
- properties
• colors
• position and type
• attenuation

Graphics Lecture 6: Slide 83 Graphics Lecture 6: Slide 84

21
Light Sources (cont.) Types of Lights

• Light color properties • OpenGL supports two types of Lights


- GL_AMBIENT - Local (Point) light sources
- GL_DIFFUSE - Infinite (Directional) light sources
- GL_SPECULAR • Type of light controlled by w coordinate

Graphics Lecture 6: Slide 85 Graphics Lecture 6: Slide 86

Turning on the Lights Light Material Tutorial

• Flip each light’s switch


glEnable( GL_LIGHTn );
• Turn on the power
glEnable( GL_LIGHTING );

Graphics Lecture 6: Slide 87 Graphics Lecture 6: Slide 88

22
Controlling a Light’s Position Light Position Tutorial

• Modelview matrix affects a light’s position


- Different effects based on when position is specified
• eye coordinates
• world coordinates
• model coordinates
- Push and pop matrices to uniquely control a light’s position

Graphics Lecture 6: Slide 89 Graphics Lecture 6: Slide 90

Advanced Lighting Features Advanced Lighting Features

• Spotlights • Light attenuation


- localize lighting affects - decrease light intensity with distance
• GL_SPOT_DIRECTION • GL_CONSTANT_ATTENUATION
• GL_SPOT_CUTOFF • GL_LINEAR_ATTENUATION
• GL_SPOT_EXPONENT • GL_QUADRATIC_ATTENUATION

Graphics Lecture 6: Slide 91 Graphics Lecture 6: Slide 92

23
Light Model Properties Tips for Better Lighting
glLightModelfv( property, value ); • Recall lighting computed only at vertices
• Enabling two sided lighting - model tessellation heavily affects lighting results
GL_LIGHT_MODEL_TWO_SIDE • better results but more geometry to process
• Global ambient color • Use a single infinite light for fastest lighting
GL_LIGHT_MODEL_AMBIENT - minimal computation per vertex
• Local viewer mode
GL_LIGHT_MODEL_LOCAL_VIEWER
• Separate specular color
GL_LIGHT_MODEL_COLOR_CONTROL

Graphics Lecture 6: Slide 93 Graphics Lecture 6: Slide 94

On-Line Resources Books


- http://www.opengl.org
• OpenGL Programming Guide, 3rd Edition
• start here; up to date specification and lots of sample code
- news:comp.graphics.api.opengl • OpenGL Reference Manual, 3rd Edition
- http://www.sgi.com/software/opengl
- http://www.mesa3d.org/
• OpenGL Programming for the X Window System
• Brian Paul’s Mesa 3D - includes many GLUT examples
- http://www.cs.utah.edu/~narobins/opengl.html
• very special thanks to Nate Robins for the OpenGL Tutors
• Interactive Computer Graphics: A top-down approach
• source code for tutors available here! with OpenGL, 2nd Edition

Graphics Lecture 6: Slide 95 Graphics Lecture 6: Slide 96

24

You might also like