Archived

This topic is now archived and is closed to further replies.

DoronSh

Problem with lighting and colors

Recommended Posts

I''m new to opengl so I''m trying to learn from the tuts here until my red book arrive. I got a problem with coloring a sphere and enabling light. I drew a sphere and colored it green using the glColor func but when i enabled the light it became black & white. Is there something I''m missing here? I''d really appritiate it if you''d help me. BTW do I need to define normals for a sphere ( it''s round so I don''t see how...) ?

Share this post


Link to post
Share on other sites
Look into the material color instead of just glColor*...

from gl.h
glMaterialf (GLenum face, GLenum pname, GLfloat param);
glMaterialfv (GLenum face, GLenum pname, GLfloat *params);

face - GL_FRONT, GL_BACK or GL_FRONT_AND_BACK ... I''m sure you''ve seen this in other functions too

pname - GL_AMBIENT, GL_DIFFUSE, GL_AMBIENT_AND_DIFFUSE, GL_SPECULAR, GL_SHININESS, GL_EMISSION (some uses one parameter, others 4)

It is much like configuring lights

float red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);


I think that''s about it... that should do it...

/G

Share this post


Link to post
Share on other sites
having just conquered the same problem 2 days ago all you need to do is:

glEnable(GL_COLOR_MATERIAL);

leave everything else as is, and it'll work fine

-me

[edited by - Palidine on July 15, 2002 6:01:44 PM]

Share this post


Link to post
Share on other sites