forked from Blackcatn13/houseDesigner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIllumination.cpp
More file actions
56 lines (45 loc) · 1.3 KB
/
Illumination.cpp
File metadata and controls
56 lines (45 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "Illumination.h"
Illumination::Illumination()
{
// Init illumination
// (setting it for fixed functiony, will be bypassed by the shaders if active)
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
// default components for global illumination
pos[0] = 0.0; pos[1] = 0.0; pos[2] = 1.0; pos[3] = 1.0;
dif[0] = 0.5; dif[1] = 0.5; dif[2] = 0.5; dif[3] = 1.0;
amb[0] = 0.0; amb[1] = 0.0; amb[2] = 0.0; amb[3] = 1.0;
spe[0] = 0.0; spe[1] = 0.0; spe[2] = 0.0; spe[3] = 1.0;
}
Illumination::~Illumination()
{
}
void Illumination::update()
{
glDisable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_POSITION, pos);
glLightfv(GL_LIGHT0,GL_DIFFUSE, dif);
glLightfv(GL_LIGHT0,GL_SPECULAR, spe);
glLightfv(GL_LIGHT0,GL_AMBIENT, amb);
glEnable(GL_LIGHT0);
}
void Illumination::draw()
{
// Turn light off for light prop.
// This light trick will only work on fixed function.
// You are free to implement specific action for your
// custom shaders!
glDisable(GL_LIGHTING);
glPushMatrix();
glColor3f(0.8f, 0.8f, 0.0f);
glTranslatef(pos[0],pos[1],pos[2]);
glutSolidSphere(.1,10,10);
glPopMatrix();
glEnable(GL_LIGHTING);
}
void Illumination::move(float ah, float av)
{
pos[0] += ah;
pos[1] += av;
}