5. OpenGL s
State
Machine
• All
rendering
a<ributes
are
encapsulated
in
the
OpenGL
State
– rendering
styles
– shading
– ligh?ng
– texture
mapping
5
6. Manipula?ng
OpenGL
State
• Appearance
is
controlled
by
current
state
for
each
(
primi?ve
to
render
)
{
update
OpenGL
state
render
primi?ve
}
• Manipula?ng
vertex
a<ributes
is
most
common
way
to
manipulate
state
glColor*() / glIndex*()
glNormal*()
glTexCoord*()
6
7. Controlling
current
state
• SeKng
State
glPointSize( size );
glLineStipple( repeat, pattern );
glShadeModel( GL_SMOOTH );
• Enabling
Features
glEnable( GL_LIGHTING );
glDisable( GL_TEXTURE_2D );
7
8. Camera
Analogy
• 3D
is
just
like
taking
a
photograph
(lots
of
photographs!)
viewing
volume
camera
tripod
model
8
9. Camera
Analogy
and
Transforma?ons
• Projec?on
transforma?ons
– adjust
the
lens
of
the
camera
• Viewing
transforma?ons
– tripod–define
posi?on
and
orienta?on
of
the
viewing
volume
in
the
world
• Modeling
transforma?ons
– moving
the
model
• Viewport
transforma?ons
– enlarge
or
reduce
the
physical
photograph
9
10. Transforma?on
Poly.
Per
Vertex
Pipeline
CPU
DL
Pixel
Texture
Raster
Frag
FB
object eye clip normalized window
device
v
e
r Modelview Projection Perspective Viewport
t
e Matrix Matrix Division Transform
x
Modelview Projection
• other
calcula?ons
here
– material
è
color
Modelview – shade
model
(flat)
– polygon
rendering
mode
l
l – polygon
culling
l – clipping
10