Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic OpenGL lighting question

I think this is an extremely stupid and newbie question, but then I am a newbie in graphics and openGL. Having drawn a sphere and put a light source nearby, also having specified ambient light, I started experimenting with light and material values and came to a surprising conclusion: the colors which we specify with glColor* do not matter at all when lighting is enabled. Instead, the equivalent is the material's ambient component. Is this conclusion correct? Thanks

like image 271
Armen Tsirunyan Avatar asked Feb 25 '23 20:02

Armen Tsirunyan


1 Answers

If the lighting is enabled, then instead of the vertex color, the material color (well, colors - there are several of them for different types of response to light) is used. Material colors are specified by glMaterial* functions.

If you want to reuse your code, you can use glEnable(GL_COLOR_MATERIAL) and glColorMaterial(GL_AMBIENT_AND_DIFFUSE) to have your old glColor* calls mapped to material color automatically.

(And please switch to shaders as fast as possible - the shader approach is both easier and more powerful)

like image 63
Kos Avatar answered Mar 07 '23 05:03

Kos