-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlight_controller.h
More file actions
99 lines (83 loc) · 1.94 KB
/
light_controller.h
File metadata and controls
99 lines (83 loc) · 1.94 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Computer Graphics Assignment 3 -
* Mitchell Anderson, Andrew Pham, Konrad Janica
*
* light_controller.h, definition of phong lighting models in openGL
*
* This file is a definition of phong lighting models in openGL
* including spotlights, point lights and directional lights
*
*
*/
#ifndef ASSIGN3_LIGHT_CONTROLLER_H_
#define ASSIGN3_LIGHT_CONTROLLER_H_
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <GL/glew.h>
#include "glm/glm.hpp"
#include "glm/gtc/type_ptr.hpp"
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
// The light structures help the LightController class deal with light input
struct BaseLight
{
glm::vec3 AmbientIntensity;
glm::vec3 DiffuseIntensity;
glm::vec3 SpecularIntensity;
BaseLight()
{
AmbientIntensity = glm::vec3(0.0f, 0.0f, 0.0f);
DiffuseIntensity = glm::vec3(0.0f, 0.0f, 0.0f);
SpecularIntensity = glm::vec3(0.0f, 0.0f, 0.0f);
}
};
struct DirectionalLight : BaseLight
{
glm::vec3 Direction;
DirectionalLight()
{
Direction = glm::vec3(0.0f, 0.0f, 0.0f);
}
};
struct PointLight : BaseLight
{
glm::vec3 Position;
struct
{
float Constant;
float Linear;
float Exp;
} Attenuation;
PointLight()
{
Position = glm::vec3(0.0f, 0.0f, 0.0f);
Attenuation.Constant = 1.0f;
Attenuation.Linear = 0.0f;
Attenuation.Exp = 0.0f;
}
};
struct SpotLight : PointLight
{
glm::vec3 Direction;
float CosineCutoff;
SpotLight()
{
Direction = glm::vec3(0.0f, 0.0f, 0.0f);
CosineCutoff = 0.0f;
}
};
// Class to take care of sending light data into shader program
class LightController
{
public:
// Sets light properties
void SetDirectionalLight(GLuint program_id, const DirectionalLight& light);
void SetPointLights(GLuint program_id, unsigned int numLights, const PointLight* lights);
void SetSpotLights(GLuint program_id, unsigned int numLights, const SpotLight* lights);
};
#endif