Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: simple lighting of a shaded cube

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    norman, oklahoma
    Posts
    1

    simple lighting of a shaded cube

    I have a rotating cube, each vertice is a different color so the colors are smoothly shaded across each face. I am trying to add a simple light to the scene just to experiment with it. Every time I enable lighting, the cube turns into black and white. I obviously do not have the material values of the cube set correctly, or the light values set correctly or something. Can someone tell me what values to use for the material of the cube, or the properties of the ligh, so that it will retain its smoothly shaded surface when the light strikes it. Thanks in advance.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    State College, PA
    Posts
    186

    Re: simple lighting of a shaded cube

    You need to set the material color of the faces, not the colors of the vertices.

    Chris

  3. #3
    Intern Contributor
    Join Date
    Mar 2001
    Posts
    64

    Re: simple lighting of a shaded cube

    You can also enable color tracking for your material using-

    glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_D IFFUSE)
    and...
    glEnable(GL_COLOR_MATERIAL)

    As long as you define a material with ambient and diffuse properties, you can then go ahead and change it's colors on the fly.

    Then you can still have your vertex colors and if the Model Shading is set to Smooth, they will be blended.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •