23 #ifndef SHADERPROGRAM_H
24 #define SHADERPROGRAM_H
33 MAX_UNIFORM_LOCATIONS = 30
59 void setAttributeArray(
int location,
const float *values,
int size,
int stride = 0) { glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, stride, values); }
61 void setAttributeValue(
int location,
float x,
float y) { glVertexAttrib2f(location, x, y); }
62 void setAttributeValue(
int location,
float x,
float y,
float z) { glVertexAttrib3f(location, x, y,
z); }
68 void setUniformValue(
int location,
const Color& color) { glUniform4f(m_uniformLocations[location], color.
rF(), color.
gF(), color.
bF(), color.
aF()); }
69 void setUniformValue(
int location,
int value) { glUniform1i(m_uniformLocations[location], value); }
70 void setUniformValue(
int location,
float value) { glUniform1f(m_uniformLocations[location], value); }
71 void setUniformValue(
int location,
float x,
float y) { glUniform2f(m_uniformLocations[location], x, y); }
72 void setUniformValue(
int location,
float x,
float y,
float z) { glUniform3f(m_uniformLocations[location], x, y,
z); }
73 void setUniformValue(
int location,
float x,
float y,
float z,
float w) { glUniform4f(m_uniformLocations[location], x, y,
z, w); }
76 void setUniformValue(
const char *name,
const Color& color) { glUniform4f(glGetUniformLocation(m_programId, name), color.
rF(), color.
gF(), color.
bF(), color.
aF()); }
77 void setUniformValue(
const char *name,
int value) { glUniform1i(glGetUniformLocation(m_programId, name), value); }
78 void setUniformValue(
const char *name,
float value) { glUniform1f(glGetUniformLocation(m_programId, name), value); }
79 void setUniformValue(
const char *name,
float x,
float y) { glUniform2f(glGetUniformLocation(m_programId, name), x, y); }
80 void setUniformValue(
const char *name,
float x,
float y,
float z) { glUniform3f(glGetUniformLocation(m_programId, name), x, y,
z); }
81 void setUniformValue(
const char *name,
float x,
float y,
float z,
float w) { glUniform4f(glGetUniformLocation(m_programId, name), x, y,
z, w); }
82 void setUniformValue(
const char *name,
const Matrix2& mat) { glUniformMatrix2fv(glGetUniformLocation(m_programId, name), 1, GL_FALSE, mat.
data()); }
83 void setUniformValue(
const char *name,
const Matrix3& mat) { glUniformMatrix3fv(glGetUniformLocation(m_programId, name), 1, GL_FALSE, mat.
data()); }
93 static uint m_currentProgram;
95 std::array<int, MAX_UNIFORM_LOCATIONS> m_uniformLocations;