diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-03 19:47:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-03 19:48:31 +0000 |
commit | c3eea71370eb94cff1fd96185458643fab6eb2c5 (patch) | |
tree | cb331dd81d9cb36d69e1b659353796ec170a78e4 /gfx/gl/program.cpp | |
parent | Rename Shader to SceneShader (diff) | |
download | ilt-c3eea71370eb94cff1fd96185458643fab6eb2c5.tar.bz2 ilt-c3eea71370eb94cff1fd96185458643fab6eb2c5.tar.xz ilt-c3eea71370eb94cff1fd96185458643fab6eb2c5.zip |
Restructure how shaders are worked with
Needs a tidy-up
Diffstat (limited to 'gfx/gl/program.cpp')
-rw-r--r-- | gfx/gl/program.cpp | 35 |
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"); + } +} |