Lighting in OpenGL

Tom Kelliher, CS 320

Apr. 16, 2003

Administrivia

Announcements

Take-home exam will be distributed Monday. Due beginning of class Wednesday.

Project 3 due now.

Assignment

Read 6.7--9 (6.1--5).

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

From Last Time

Project day.

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
Tue Apr 15 09:06:18 EDT 2003
Tom Kelliher