1 /*
2 This file is a part of the RepSnapper project.
3 Copyright (C) 2010 Evan Clinton (Palomides)
4
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 2 of the License, or
8 (at your option) any later version.
9
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.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "stdafx.h"
21 #include "gllight.h"
22
gllight()23 gllight::gllight()
24 {
25 Init(GL_LIGHT0);
26 }
27
~gllight()28 gllight::~gllight()
29 {
30 }
31
Init(int position)32 void gllight::Init(int position)
33 {
34 offset = position;
35 }
36
Enable(bool on)37 void gllight::Enable(bool on)
38 {
39 if (on)
40 glEnable(offset);
41 else
42 glDisable(offset);
43 }
44
SetAmbient(float r,float g,float b,float a)45 void gllight::SetAmbient(float r, float g, float b, float a)
46 {
47 float ambient[] = {r,g,b,a};
48 glLightfv(offset, GL_AMBIENT, ambient);
49 }
50
SetDiffuse(float r,float g,float b,float a)51 void gllight::SetDiffuse(float r, float g, float b, float a)
52 {
53 float diffuse[] = {r,g,b,a};
54 glLightfv(offset, GL_DIFFUSE, diffuse);
55 }
56
SetLocation(float x,float y,float z,float w)57 void gllight::SetLocation(float x, float y, float z, float w)
58 {
59 float position[] = {x,y,z,w};
60 glLightfv(offset, GL_POSITION, position);
61 }
62
SetSpecular(float r,float g,float b,float a)63 void gllight::SetSpecular(float r, float g, float b, float a)
64 {
65 float specular[] = {r,g,b,a};
66 glLightfv ( offset, GL_SPECULAR, specular );
67 }
68