OpenGL State

GL rendering consists of geometry + state



Both are passed to graphics hardware via function calls



To draw something, the necessary state attributes (e.g. color) are set first
Then, the geometry (e.g. triangle data) is passed




State is retained until changed
State changes do not affect any geometry already drawn




State includes:





Example:

glColor3f(1, 1, 0)      # Set current color

glBegin(GL_TRIANGLES)

glVertex2f(0.0, 0.0)	# This triangle is yellow
glVertex2f(0.4, 0.0)
glVertex2f(0.8, 0.8)

glColor3f(1, 0, 1)      # Change current color
glVertex2f(0.0, 0.0)	# This triangle is magenta
glVertex2f(-0.4, 0.0)
glVertex2f(-0.8, -0.8)

glEnd()


next