pointLight()
Lights Camera / LightsDescription
Adds a point light. Emanates from a specific position in all directions.
Syntax
void pointLight(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 | float | x-position |
| y | float | y-position |
| z | float | z-position |
Returns
voidRelated
Under the Hood
From Processing.h:
void pointLight(float r, float g, float b, float x, float y, float z);
inline void PGraphics::pointLight(float r, float g, float b, float x, float y, float z) { if(PApplet::g_papplet) PApplet::g_papplet->pointLight(r,g,b,x,y,z); }
Under the Hood
From Processing.cpp:
void PApplet::pointLight(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 }; // w=1 = positional
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_AMBIENT_AND_DIFFUSE);
glEnable(lt);
glLightfv(lt, GL_AMBIENT, zero);
glLightfv(lt, GL_DIFFUSE, col);
glLightfv(lt, GL_SPECULAR, zero);
glLightf(lt, GL_CONSTANT_ATTENUATION, 1.0f);
glLightf(lt, GL_LINEAR_ATTENUATION, 0.0f);
glLightf(lt, GL_QUADRATIC_ATTENUATION, 0.0f);
// Position transformed by current modelview (world space)
glLightfv(lt, GL_POSITION, pos);
}