BARE2D
ShaderProgram.tcc
Go to the documentation of this file.
1 #pragma once
2 
3 #include <typeinfo>
4 
5 #include <glm/glm.hpp>
6 #include <glm/gtc/type_ptr.hpp>
7 
8 #include "BAREErrors.hpp"
9 
10 namespace BARE2D {
11  template<class T>
12  void ShaderProgram::setUniform(const std::string uniform, T* data, unsigned int num) {
13  throwFatalError(BAREError::GLSL_PROGRAM_FAILURE, "Tried calling setUniform with unsupported type: " + demangle(typeid(*data).name()));
14  }
15 
16  template<class T>
17  void ShaderProgram::setUniformMatrix(const std::string uniform, bool transpose, T* data, unsigned int num) {
18  throwFatalError(BAREError::GLSL_PROGRAM_FAILURE, "Tried calling setUniformMatrix with unsupported type: " + demangle(typeid(*data).name()));
19  }
20 
21  // Template specialization declarations
22 
23  template<>
24  void ShaderProgram::setUniform<int>(const std::string uniform, int* data, unsigned int num);
25  template<>
26  void ShaderProgram::setUniform<unsigned int>(const std::string uniform, unsigned int* data, unsigned int num);
27  template<>
28  void ShaderProgram::setUniform<float>(const std::string uniform, float* data, unsigned int num);
29  template<>
30  void ShaderProgram::setUniform<glm::vec2>(const std::string uniform, glm::vec2* data, unsigned int num);
31  template<>
32  void ShaderProgram::setUniform<glm::vec3>(const std::string uniform, glm::vec3* data, unsigned int num);
33  template<>
34  void ShaderProgram::setUniform<glm::vec4>(const std::string uniform, glm::vec4* data, unsigned int num) ;
35  template<>
36  void ShaderProgram::setUniform<glm::ivec2>(const std::string uniform, glm::ivec2* data, unsigned int num) ;
37  template<>
38  void ShaderProgram::setUniform<glm::ivec3>(const std::string uniform, glm::ivec3* data, unsigned int num);
39  template<>
40  void ShaderProgram::setUniform<glm::ivec4>(const std::string uniform, glm::ivec4* data, unsigned int num) ;
41  template<>
42  void ShaderProgram::setUniformMatrix<glm::mat4>(const std::string uniform, bool transpose, glm::mat4* data, unsigned int num);
43 }