Jump to content
  • Advertisement

Archived

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

DoronSh

Problem with lighting and colors

This topic is 5942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!