Lighting in OpenGL

Tom Kelliher, CS 320

Apr. 3, 1998

Announcements:

From last time:

  1. Lighting models.

  2. Project 3 lab.

Outline:

  1. Introduction to lighting in OpenGL

  2. OpenGL lighting demo/lab.

Assignment: Do/finish the lab, run lightlab.c with flat shading rather than smooth shading.

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
Thu Apr 2 13:57:17 EST 1998
Tom Kelliher