13 EXPORT
static int counter;
16 EXPORT
static int bound;
24 std::vector<GLuint> attached;
26 std::map<std::string, GLenum> shader_path_map;
28 std::map<std::string, GLenum> shader_string_map;
30 static std::vector<std::string> paths;
44 EXPORT
static void add_path(std::string path);
60 EXPORT
bool attach_file(
const std::string& filename, GLenum type);
67 EXPORT
bool attach_string(
const std::string& shader_string, GLenum type);
112 template <
typename T>
119 template <
typename T>
127 template <
typename T>
135 template <
typename T>
144 template <
typename T>
153 template <
typename T>
163 template <
typename T>
173 template <
typename T>
174 void set_uniform(
const std::string& name, T v0, T v1, T v2, T v3);
182 template <
typename T>
184 unsigned int elements,
const T *value);
192 template <
typename T>
194 unsigned int elements,
const T *value);
204 template <
typename T>
207 unsigned int columns,
220 template <
typename T>
223 unsigned int columns,
232 EXPORT
void set_uniform(
int location,
const glm::vec2& value);
238 EXPORT
void set_uniform(
int location,
const glm::dvec2& value);
244 EXPORT
void set_uniform(
int location,
const glm::vec3& value);
250 EXPORT
void set_uniform(
int location,
const glm::dvec3& value);
256 EXPORT
void set_uniform(
int location,
const glm::vec4& value);
262 EXPORT
void set_uniform(
int location,
const glm::dvec4& value);
269 const glm::vec2& value);
276 const glm::dvec2& value);
283 const glm::vec3& value);
290 const glm::dvec3& value);
297 const glm::vec4& value);
304 const glm::dvec4& value);
313 const glm::mat2& value);
322 const glm::dmat2& value);
331 const glm::mat3& value);
340 const glm::dmat3& value);
349 const glm::mat4& value);
358 const glm::dmat4& value);
367 const glm::mat2& value);
376 const glm::dmat2& value);
385 const glm::mat3& value);
394 const glm::dmat3& value);
403 const glm::mat4& value);
412 const glm::dmat4& value);
419 const std::vector<glm::vec2>& value);
426 const std::vector<glm::dvec2>& value);
433 const std::vector<glm::vec3>& value);
440 const std::vector<glm::dvec3>& value);
447 const std::vector<glm::vec4>& value);
454 const std::vector<glm::dvec4>& value);
461 const std::vector<glm::vec2>& value);
468 const std::vector<glm::dvec2>& value);
475 const std::vector<glm::vec3>& value);
482 const std::vector<glm::dvec3>& value);
489 const std::vector<glm::vec4>& value);
496 const std::vector<glm::dvec4>& value);
505 const std::vector<glm::mat2>& value);
514 const std::vector<glm::dmat2>& value);
523 const std::vector<glm::mat3>& value);
532 const std::vector<glm::dmat3>& value);
541 const std::vector<glm::mat4>& value);
550 const std::vector<glm::dmat4>& value);
559 const std::vector<glm::mat2>& value);
568 const std::vector<glm::dmat2>& value);
577 const std::vector<glm::mat3>& value);
586 const std::vector<glm::dmat3>& value);
595 const std::vector<glm::mat4>& value);
604 const std::vector<glm::dmat4>& value);
610 glUniform1i(location, v0);
616 glUniform1ui(location, v0);
622 glUniform1f(location, v0);
628 glUniform1d(location, v0);
658 glUniform2i(location, v0, v1);
664 glUniform2ui(location, v0, v1);
670 glUniform2f(location, v0, v1);
676 glUniform2d(location, v0, v1);
706 glUniform3i(location, v0, v1, v2);
712 glUniform3ui(location, v0, v1, v2);
718 glUniform3f(location, v0, v1, v2);
724 glUniform3d(location, v0, v1, v2);
754 glUniform4i(location, v0, v1, v2, v3);
760 glUniform4ui(location, v0, v1, v2, v3);
766 glUniform4f(location, v0, v1, v2, v3);
772 glUniform4d(location, v0, v1, v2, v3);
808 glUniform1iv(location, count, value);
811 glUniform2iv(location, count, value);
814 glUniform3iv(location, count, value);
817 glUniform4iv(location, count, value);
820 std::string error =
"Wrong number of elements given to"
821 "the set_uniform function";
823 throw std::runtime_error(error);
837 glUniform1uiv(location, count, value);
840 glUniform2uiv(location, count, value);
843 glUniform3uiv(location, count, value);
846 glUniform4uiv(location, count, value);
849 std::string error =
"Wrong number of elements given to"
850 "the set_uniform function";
852 throw std::runtime_error(error);
866 glUniform1fv(location, count, value);
869 glUniform2fv(location, count, value);
872 glUniform3fv(location, count, value);
875 glUniform4fv(location, count, value);
878 std::string error =
"Wrong number of elements given to"
879 "the set_uniform function";
881 throw std::runtime_error(error);
895 glUniform1dv(location, count, value);
898 glUniform2dv(location, count, value);
901 glUniform3dv(location, count, value);
904 glUniform4dv(location, count, value);
907 std::string error =
"Wrong number of elements given to"
908 "the set_uniform function";
910 throw std::runtime_error(error);
916inline void Shader::set_uniform<int>(
const std::string& name,
unsigned int count,
unsigned int elements,
const int *value) {
930inline void Shader::set_uniform<float>(
const std::string& name,
unsigned int count,
unsigned int elements,
const float *value) {
944inline void Shader::set_uniform<float>(
int location,
unsigned int count,
unsigned int columns,
unsigned int rows,
bool transpose,
const float *value) {
947 if(columns < 2 || rows < 2 || columns > 4 || rows > 4)
952 if(columns == rows) {
955 glUniformMatrix2fv(location,
961 glUniformMatrix3fv(location,
967 glUniformMatrix4fv(location,
973 std::string error =
"Wrong number of elements given to"
974 "the set_uniform function";
976 throw std::runtime_error(error);
980 if(columns == 2 && rows == 3) {
981 glUniformMatrix2x3fv(location, count, transpose, value);
982 }
else if(columns == 3 && rows == 2) {
983 glUniformMatrix3x2fv(location, count, transpose, value);
984 }
else if(columns == 2 && rows == 4) {
985 glUniformMatrix2x4fv(location, count, transpose, value);
986 }
else if(columns == 4 && rows == 2) {
987 glUniformMatrix4x2fv(location, count, transpose, value);
988 }
else if(columns == 3 && rows == 4) {
989 glUniformMatrix3x4fv(location, count, transpose, value);
990 }
else if(columns == 4 && rows == 3) {
991 glUniformMatrix4x3fv(location, count, transpose, value);
993 std::string error =
"Wrong number of elements given to"
994 "the set_uniform function";
996 throw std::runtime_error(error);
1002inline void Shader::set_uniform<double>(
int location,
unsigned int count,
unsigned int columns,
unsigned int rows,
bool transpose,
const double *value) {
1005 if(columns < 2 || rows < 2 || columns > 4 || rows > 4)
1010 if(columns == rows) {
1013 glUniformMatrix2dv(location,
1019 glUniformMatrix3dv(location,
1025 glUniformMatrix4dv(location,
1031 std::string error =
"Wrong number of elements given to"
1032 "the set_uniform function";
1034 throw std::runtime_error(error);
1039 if(columns == 2 && rows == 3) {
1040 glUniformMatrix2x3dv(location, count, transpose, value);
1041 }
else if(columns == 3 && rows == 2) {
1042 glUniformMatrix3x2dv(location, count, transpose, value);
1043 }
else if(columns == 2 && rows == 4) {
1044 glUniformMatrix2x4dv(location, count, transpose, value);
1045 }
else if(columns == 4 && rows == 2) {
1046 glUniformMatrix4x2dv(location, count, transpose, value);
1047 }
else if(columns == 3 && rows == 4) {
1048 glUniformMatrix3x4dv(location, count, transpose, value);
1049 }
else if(columns == 4 && rows == 3) {
1050 glUniformMatrix4x3dv(location, count, transpose, value);
1052 std::string error =
"Wrong number of elements given to"
1053 "the set_uniform function";
1055 throw std::runtime_error(error);
1061inline void Shader::set_uniform<float>(
const std::string& name,
unsigned int count,
unsigned int columns,
unsigned int rows,
bool transpose,
const float *value) {
1064 set_uniform(loc, count, columns, rows, transpose, value);
1068inline void Shader::set_uniform<double>(
const std::string& name,
unsigned int count,
unsigned int columns,
unsigned int rows,
bool transpose,
const double *value) {
1071 set_uniform(loc, count, columns, rows, transpose, value);
static std::vector< std::string > error_string
A list of all error strings.
void set_uniform(int location, T v0, T v1, T v2)
Sets the uniform.
bool link()
Links the attached shaders.
void set_uniform(int location, unsigned int count, unsigned int columns, unsigned int rows, bool transpose, const T *value)
Sets the uniform.
void unbind()
Unbinds the shader and restores the previously bound shader.
void set_uniform(int location, unsigned int count, unsigned int elements, const T *value)
Sets the uniform.
bool attach_file(const std::string &filename, GLenum type)
Compiles and attaches shader files.
bool attach_string(const std::string &shader_string, GLenum type)
Compiles and attaches shader strings.
void set_uniform(const std::string &name, T v0, T v1, T v2)
Sets the uniform.
void recompile()
Reads, compiles and links all associated shaders again.
int get_attribute_location(const std::string &name)
Returns the location of an attribute variable.
void set_transform_feedback_variables(std::vector< std::string > &variables, GLenum buffer_mode)
Sets the variable to record in transform feedback buffers.
void set_uniform(const std::string &name, T v0, T v1, T v2, T v3)
Sets the uniform.
bool transform_feedback
True if the shader records values into transform feedback buffer(s)
void set_uniform(int location, T v0)
Sets the uniform.
void set_uniform(int location, T v0, T v1)
Sets the uniform.
void bind()
Binds the shader and stores the previously bound shader.
void set_uniform(const std::string &name, unsigned int count, unsigned int elements, const T *value)
Sets the uniform.
GLuint program
Shader name.
void set_uniform(const std::string &name, T v0, T v1)
Sets the uniform.
void set_uniform(const std::string &name, unsigned int count, unsigned int columns, unsigned int rows, bool transpose, const T *value)
Sets the uniform.
void set_uniform(int location, T v0, T v1, T v2, T v3)
Sets the uniform.
void set_uniform(const std::string &name, T v0)
Sets the uniform.
int get_uniform_location(const std::string &name)
Returns the location of a uniform variable.
static void add_path(std::string path)
Adds a path to the list of paths to be searched ▸ for image files.