22 struct ShaderProgramDeleter {
23 void operator()(
unsigned int* programId) {
24 if (programId !=
nullptr) {
25 glDeleteProgram(*programId);
31 std::shared_ptr<unsigned int> p_programId;
43 template<typename... Shaders>
61 MYGL_EXPORT
void use() const;
79 MYGL_EXPORT
void setMat4(const std::
string& name, const glm::mat4& value) const;
87 MYGL_EXPORT
void setInt(const std::
string& name, const glm::ivec1& value) const;
91 MYGL_EXPORT
void setInt(const std::
string& name, const glm::ivec2& value) const;
95 MYGL_EXPORT
void setInt(const std::
string& name, const glm::ivec3& value) const;
99 MYGL_EXPORT
void setInt(const std::
string& name, const glm::ivec4& value) const;
106 template<typename... Args>
107 inline
void setInt(const std::
string& name,
int v0, Args... values) const;
117 MYGL_EXPORT
void setUInt(const std::
string& name, const glm::uvec1& value) const;
121 MYGL_EXPORT
void setUInt(const std::
string& name, const glm::uvec2& value) const;
125 MYGL_EXPORT
void setUInt(const std::
string& name, const glm::uvec3& value) const;
129 MYGL_EXPORT
void setUInt(const std::
string& name, const glm::uvec4& value) const;
136 template<typename... Args>
137 inline
void setUInt(const std::
string& name,
unsigned int v0, Args... values) const;
147 MYGL_EXPORT
void setFloat(const std::
string& name, const glm::vec1& value) const;
151 MYGL_EXPORT
void setFloat(const std::
string& name, const glm::vec2& value) const;
155 MYGL_EXPORT
void setFloat(const std::
string& name, const glm::vec3& value) const;
159 MYGL_EXPORT
void setFloat(const std::
string& name, const glm::vec4& value) const;
166 template<typename... Args>
167 inline
void setFloat(const std::
string& name,
float v0, Args... values) const;
179 if (p_programId ==
nullptr) {
180 const unsigned int programId = glCreateProgram();
181 if (programId == 0) {
182 std::cerr <<
"ERROR::SHADER PROGRAM: failed to create a shader program\n";
185 p_programId.reset(
new unsigned int{programId}, ShaderProgramDeleter());
188 for (
const Shader& s : {shader, shaders...}) {
190 std::cerr <<
"ERROR::SHADER PROGRAM: one of the provided shaders is not usable\n";
193 glAttachShader(*p_programId, *s.p_shaderId);