Jump to content
  • Advertisement

Archived

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

Muncher

gl Lighting problems

This topic is 5556 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

Hey! When lighting is enabled in OpenGL, all polygons turn shades of grey, ie/ glVertex3f() seems to have no effect, how do i stop this because i want colors? Without using glMaterialfv()?? Cheers all Muncher

Share this post


Link to post
Share on other sites
Advertisement
you first need to enable color materials by calling
glEnable(GL_COLOR_MATERIAL)

then you could set the property that glColor*() effects by calling

glColorMaterial(GLenum face, GLenum mode);

where face is one of...
GL_FRONT
GL_BACK
GL_FRONT_AND_BACK

and mode is one of
GL_AMBIENT
GL_DIFFUSE
GL_SPECULAR
GL_AMBIENT_AND_DIFFUSE
GL_EMISSION

then setting the color using glColor*() will change only the property you selected for mode.

if you need to change another material property you can still use

glMaterial{if}(GLenum face, GLenum pname, TYPE param)
or
glMaterial{if}v(GLenum face, GLenum pname, TYPE *param)

where face is one of...
GL_FRONT
GL_BACK
GL_FRONT_AND_BACK

and pname is one of...
GL_AMBIENT
GL_DIFFUSE
GL_AMBIENT_AND_DIFFUSE
GL_SPECULAR
GL_SHININESS
GL_EMISSION

and param is the values for that property

you can only choose one material property at a time using glColorMaterial so its still best to use glMaterialfv().

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!