2
* lights.cpp - OpenGL Lighting implementation
3
* Copyright (C) 2007, D Haley
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
Light::Light() : active(false)
24
for(unsigned int ui=0; ui<3; ui++)
26
ambientColour[ui] = 1.0f;
27
diffuseColour[ui] = 1.0f;
28
specularColour[ui] = 1.0f;
30
origin = Point3D(0.0f,0.0f,0.0f);
37
void Light::setActive(bool b)
42
bool Light::isActive() const
47
void Light::setLightNum(unsigned int ln)
52
void Light::setOrigin(const Point3D &p)
57
void Light::setColour(unsigned int mode, float r, float g, float b)
72
specularColour[0] = r;
73
specularColour[1] = g;
74
specularColour[2] = b;
82
void Light::apply() const
87
origin.copyValueArr(f);
89
glLightfv(lightNum, GL_AMBIENT, ambientColour);
90
glLightfv(lightNum, GL_DIFFUSE, diffuseColour);
91
glLightfv(lightNum, GL_SPECULAR, specularColour);
92
glLightfv(lightNum, GL_POSITION, f);