ambientLight()
Lights Camera / LightsDescription
Adds an ambient light. Ambient light has no position or direction.
Syntax
void ambientLight(float r, float g, float b)
void ambientLight(float r, float g, float b, float x, float y, float z)
Parameters
| Name | Type | Description |
|---|---|---|
| r | float | red component |
| g | float | green component |
| b | float | blue component |
| x/y/z | float | position (optional) |
Returns
voidRelated
Under the Hood
From Processing.h:
void ambientLight(float r, float g, float b);
void ambientLight(float r, float g, float b, float x, float y, float z);
inline void PGraphics::ambientLight(float r, float g, float b) { if(PApplet::g_papplet) PApplet::g_papplet->ambientLight(r,g,b); }
inline void PGraphics::ambientLight(float r, float g, float b, float x, float y, float z) { if(PApplet::g_papplet) PApplet::g_papplet->ambientLight(r,g,b,x,y,z); }
Under the Hood
From Processing.cpp:
void PApplet::ambientLight(float r, float g, float b) { ambientLight(r,g,b,0,0,0); }
void PApplet::ambientLight(float r, float g, float b) { ambientLight(r,g,b,0,0,0);
void PApplet::ambientLight(float r, float g, float b, float x, float y, float z) {
if (lightIndex >= 8) return;
GLenum lt = GL_LIGHT0 + lightIndex++;
GLfloat col[] = { lc(r), lc(g), lc(b), 1.0f };
GLfloat pos[] = { x, y, z, 1.0f };
GLfloat zero[]= { 0.0f, 0.0f, 0.0f, 1.0f };
glEnable(GL_LIGHTING);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(lt);
glLightfv(lt, GL_AMBIENT, col);
glLightfv(lt, GL_DIFFUSE, zero);
glLightfv(lt, GL_SPECULAR, zero);
// Position is transformed by the current modelview (world space)
glLightfv(lt, GL_POSITION, pos);
}