-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMaterial.cpp
77 lines (62 loc) · 2.26 KB
/
Material.cpp
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
#include "Material.h"
#include <iostream>
namespace tessterrain {
Material::Material(): m_shader(0) {
m_shaderDir = SHADER_DIR;
//std::cout << "Shader dir: " << SHADER_DIR << std::endl;
color = glm::vec3(1.0);
Ka = glm::vec3( 0.1f, 0.1f, 0.1f );
Kd = glm::vec3( 1.0f, 1.0f, 1.0f );
Ks = glm::vec3( 0.3f, 0.3f, 0.3f );
shininess = 1.0;
}
Material::~Material() {
if(m_shader)
delete m_shader;
}
/**
*/
MeshMaterial::MeshMaterial(): Material() {
m_shader = new GLSLProgram();
string filename;
filename = m_shaderDir; filename.append("mesh.vert");
m_shader->compileShader(filename.c_str());
filename = m_shaderDir; filename.append("mesh.frag");
m_shader->compileShader(filename.c_str());
m_shader->link();
}
MeshMaterial::~MeshMaterial() {
}
/**
*/
TessMaterial::TessMaterial(): Material() {
m_shader = new GLSLProgram();
string filename;
filename = m_shaderDir; filename.append("terrain.vert");
m_shader->compileShader(filename.c_str());
filename = m_shaderDir; filename.append("terrain.tcs");
m_shader->compileShader(filename.c_str());
filename = m_shaderDir; filename.append("terrain.tes");
m_shader->compileShader(filename.c_str());
filename = m_shaderDir; filename.append("terrain.geom");
m_shader->compileShader(filename.c_str());
filename = m_shaderDir; filename.append("terrain.frag");
m_shader->compileShader(filename.c_str());
m_shader->link();
}
TessMaterial::~TessMaterial() {
}
/**
*/
SSMaterial::SSMaterial(): Material() {
m_shader = new GLSLProgram();
string filename;
filename = m_shaderDir; filename.append("ss_display.vert");
m_shader->compileShader(filename.c_str());
filename = m_shaderDir; filename.append("ss_display.frag");
m_shader->compileShader(filename.c_str());
m_shader->link();
}
SSMaterial::~SSMaterial() {
}
}; //namespace tessterrain