|
@@ -3,7 +3,6 @@
|
3
|
3
|
Shader::Shader( std::string vert, std::string frag) {
|
4
|
4
|
vert = resource->getRealPath(vert);
|
5
|
5
|
frag = resource->getRealPath(frag);
|
6
|
|
- m_good = false;
|
7
|
6
|
// Create the program to link to.
|
8
|
7
|
m_program = glCreateProgram();
|
9
|
8
|
|
|
@@ -64,7 +63,6 @@ Shader::Shader( std::string vert, std::string frag) {
|
64
|
63
|
// Clean up :)
|
65
|
64
|
glDeleteShader( vertShader );
|
66
|
65
|
glDeleteShader( fragShader );
|
67
|
|
- m_good = true;
|
68
|
66
|
glUseProgram( 0 );
|
69
|
67
|
}
|
70
|
68
|
|
|
@@ -119,45 +117,27 @@ int Shader::link( unsigned int vertshader, unsigned int fragshader, std::string&
|
119
|
117
|
}
|
120
|
118
|
|
121
|
119
|
unsigned int Shader::getUniformLocation( std::string name ) {
|
122
|
|
- if ( !m_good ) {
|
123
|
|
- return 0;
|
124
|
|
- }
|
125
|
120
|
glUseProgram( m_program );
|
126
|
121
|
return glGetUniformLocation( m_program, name.c_str() );
|
127
|
122
|
}
|
128
|
123
|
|
129
|
124
|
void Shader::setParameter( std::string name, int foo ) {
|
130
|
|
- if ( !m_good ) {
|
131
|
|
- return;
|
132
|
|
- }
|
133
|
125
|
glUniform1i( getUniformLocation( name ), foo );
|
134
|
126
|
}
|
135
|
127
|
|
136
|
128
|
void Shader::setParameter( std::string name, float foo ) {
|
137
|
|
- if ( !m_good ) {
|
138
|
|
- return;
|
139
|
|
- }
|
140
|
129
|
glUniform1f( getUniformLocation( name ), foo );
|
141
|
130
|
}
|
142
|
131
|
|
143
|
132
|
void Shader::setParameter( std::string name, glm::mat4& foo ) {
|
144
|
|
- if ( !m_good ) {
|
145
|
|
- return;
|
146
|
|
- }
|
147
|
133
|
glUniformMatrix4fv( getUniformLocation( name ), 1, GL_FALSE, glm::value_ptr( foo ) );
|
148
|
134
|
}
|
149
|
135
|
|
150
|
136
|
void Shader::setParameter( std::string name, glm::vec4 foo ) {
|
151
|
|
- if ( !m_good ) {
|
152
|
|
- return;
|
153
|
|
- }
|
154
|
137
|
glUniform4f( getUniformLocation( name ), foo.x, foo.y, foo.z, foo.w );
|
155
|
138
|
}
|
156
|
139
|
|
157
|
140
|
void Shader::setParameter( std::string name, glm::vec2 foo ) {
|
158
|
|
- if ( !m_good ) {
|
159
|
|
- return;
|
160
|
|
- }
|
161
|
141
|
glUniform2f( getUniformLocation( name ), foo.x, foo.y );
|
162
|
142
|
}
|
163
|
143
|
|