Lighting in OpenGL

Tom Kelliher, CS 320

Apr. 15, 2011

Administrivia

Announcements

Take-home exam; you're ready now. When? (Or, keep to Apr. 29?)

Assignment

Read 6.7-9.

Do/finish the lab, run lightLab.c with flat shading rather than smooth shading.

From Last Time

Finished Phong light model.

Outline

  1. Walk-through of lighting calls in lightLab.c.

  2. Lighting lab.

Coming Up

Continuation of lab.

Lighting in OpenGL

Pertinent functions (line numbers refer to code handout):

  1. glShadeModel() (269): GL_SMOOTH, GL_FLAT

  2. glMaterial*() (271-274):
    1. Face: GL_BACK, GL_FRONT_AND_BACK

    2. Parameter name:
      1. Shininess range: 0-128.

      2. GL_AMBIENT_AND_DIFFUSE

      3. GL_EMISSION

    3. Parameter: scalar for shininess, vector for other parameters.

  3. glLight*() (145, 276-278):
    1. Light: 8 lights.

    2. Parameter name: see man page for other names

    3. Parameter: some scalar, some vector.

      The fourth value in a light's position.

  4. glEnable() (280-285):
    1. GL_LIGHTING

    2. GL_LIGHTx

    3. NORMALIZE

    glDisable()

These are all modal.

Can turn lighting on and off.

Normal normals and non-normal normals.

Hands-On Lab

Grab a copy of lightLab.c from class Web page and begin experimenting.



Thomas P. Kelliher 2011-04-14
Tom Kelliher