Lighting in OpenGL

Tom Kelliher, CS 320

Apr. 20, 2001

Administrivia

Announcements

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

Exam.

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() (253): GL_SMOOTH, GL_FLAT

  2. glMaterial*() (255--258):
    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*() (139, 260--262):
    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() (264--267):
    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 homepage and begin experimenting.



Thomas P. Kelliher
Fri Apr 20 12:09:21 EDT 2001
Tom Kelliher