summaryrefslogtreecommitdiff
path: root/gfx/gl/program.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl/program.cpp')
-rw-r--r--gfx/gl/program.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/gfx/gl/program.cpp b/gfx/gl/program.cpp
new file mode 100644
index 0000000..c36cc80
--- /dev/null
+++ b/gfx/gl/program.cpp
@@ -0,0 +1,35 @@
+#include "program.h"
+#include "shader.h"
+#include <glm/gtc/type_ptr.hpp>
+#include <glm/gtx/transform.hpp>
+#include <location.hpp>
+#include <maths.h>
+
+void
+Program::linkAndValidate() const
+{
+ glLinkProgram(m_program);
+ Shader::CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");
+
+ glValidateProgram(m_program);
+ Shader::CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Invalid shader program");
+}
+
+void
+Program::use() const
+{
+ glUseProgram(m_program);
+}
+
+Program::UniformLocation::UniformLocation(GLuint program, const char * name) :
+ location {glGetUniformLocation(program, name)}
+{
+}
+
+Program::RequiredUniformLocation::RequiredUniformLocation(GLuint program, const char * name) :
+ UniformLocation {program, name}
+{
+ if (location < 0) {
+ throw std::logic_error("Required uniform does not exist");
+ }
+}