light kills color (simple help)

light kills color (simple help)

Post by Tom Impellu » Sun, 13 Aug 1995 04:00:00



Hi, I am reading the OpenGL book from Adisson & Wesley. I am trying to
decode the light examples from there, and from the GLUT distribution.

I am trying to draw a reflective green cube in a white light.

Whenever I turn on the lights, the cube goes grey.

I try using the examples from the opengl distribution, bu those simple
examples involve a sphere which comes from a quadric.

I do not know if my problems stem from:
normals, order of lighting, or lack of material properties,
(or maybe I am screwing up somewhere).

Could someone mail me a code fragment that puts up a simple reflective object
(drawn from primitives!  so I can see the use of normals!), and
colors it, and lights it with a DIFFUSE light!

I try doing it myself but am lost amidst a sea of dead-ends and contradictions
based upon my misunderstanding.

Thanks if you can help,
Tom

 
 
 

light kills color (simple help)

Post by Lesley Kalm » Tue, 15 Aug 1995 04:00:00


|>
|> Hi, I am reading the OpenGL book from Adisson & Wesley. I am trying to
|> decode the light examples from there, and from the GLUT distribution.
|>
|> I am trying to draw a reflective green cube in a white light.
|>
|> Whenever I turn on the lights, the cube goes grey.
|>
|

When lighting is turned on, OpenGL determines color entirely
from the lighting equations, ignoring the vertex colors set
with glColor.  Use glMaterial, which goes into the lighting
equation, to describe the color of the object.  Also, remember
to enable atleast one of the lights, or ambient lighting
in the light model, when you enable lighting.

Read up on glLight, glLightModel and glMaterial for a description
of all the factors that go into lighting.

Lesley
-----------------------------------------------------------------

Silicon Graphics Computer Systems          Phone:  (415)390-3571                

 
 
 

1. Simple coloring of simple objects - help.

The following code shows me part of a polygon.
Using glColor4d I had hoped to be able to change
the color of the polygon. But no. It remains
dark grey.

What am I missing?

    GLfloat light0Pos[4] = {-1.0F,  2.0F, 0.2F, 0.0F};

    wglMakeCurrent (pDC->m_hDC, hGlrc);
    glViewport(0, 0, rcClient.right, rcClient.bottom ) ;
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT);

    glRotated(30.0, 0.0, 1.0, 0.0);
    glRotated(15.0, 1.0, 0.0, 0.0);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, light0Pos);

    glBegin(GL_POLYGON);
        glColor4d (1.0, 1.0, 1.0, 1.0);
        // ****Changing the above does not change
        // ****the color of the polygon...
        glVertex2f (0.0, 0.0);
        glVertex2f (0.0, 3.0);
        glVertex2f (4.0, 3.0);
        glVertex2f (6.0, 1.5);
        glVertex2f (4.0, 0.0);
    glEnd();
    glFlush();
    wglMakeCurrent (NULL, NULL);

--------------------------------------------------
http://www.ransen.com/cad/
CAD programs, education and consulting

2. How make a small curve?

3. Kill, kill, kill the bones.....

4. W95 and Kai's Power Tools 3 - Warning!!

5. Scaling world matrix kills light

6. Does PS CS version Adobe Gamma work with LCD monitors?

7. light help wanted-strobing lights/streaming lights??

8. Adobe Type Manager for Windows NT: it's shipping!

9. Will 3dsPRO kill Lightwave? NEWTEKS KILL

10. Help Needed: lit surfaces with colors declared at the vertices

11. Help with edit - lighting and color enhancement

12. Need help w/ simple simple 2D thing