Jump to content
  • Advertisement
Sign in to follow this  

lighting and color?

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

Many moons ago, I got really frustrated with OpenGL lighting and swore I'd never use it again. Anyhow, today I decided to give it a second chance. I added some normals to my polygons and threw the following in my drawing loop (inspired by NeHe tutorial 7): glEnable(GL_LIGHTING); GLfloat LightAmbient[]= { 0.9f, 0.9f, 0.9f, 1.0f }; GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[]= { 0.0f, 0.0f, 0.0f, 1.0f }; glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); glEnable(GL_LIGHT1); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, LightAmbient); It works, and my 3d maze looks decent. However, I'd like to add a floor to the maze and have it a completely different color (I'm thinking blue). Does anyone know how to use color and lighting? It seems to ignore my color commands when lighting is enabled? I realize I can disable lighting to draw the floor, but I'd like to have the lighting effects applied to the floor if possible. Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Advertisement
How are you doing the colouring? In particular, what colour are the walls if you're not using colours already? Are you texturing or not?

Share this post


Link to post
Share on other sites
I think I just had to do

glEnable(GL_COLOR_MATERIAL);

I thought it wasn't working since I had the ambient lighting jacked up too high. It didn't look like the lighting effects were happening.

By the way, the walls were gray before, and I am using a gray stone texture.

Mike C.
http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Quote:
Original post by mike74
Does anyone know how to use color and lighting? It seems to ignore my color commands when lighting is enabled? I realize I can disable lighting to draw the floor, but I'd like to have the lighting effects applied to the floor if possible.

When lighting is enabled, polys take the colour from the material settings (defaulting to all while). If you want to use vertex colours you want glEnable(GL_COLOR_MATERIAL) and set vertex colours to track the diffuse (and probably ambient).
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc01_58vg.asp

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!