diff options
Diffstat (limited to 'gfx/gl/uiShader.cpp')
-rw-r--r-- | gfx/gl/uiShader.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/gfx/gl/uiShader.cpp b/gfx/gl/uiShader.cpp index fbcdd15..78e0064 100644 --- a/gfx/gl/uiShader.cpp +++ b/gfx/gl/uiShader.cpp @@ -1,6 +1,6 @@ #include "uiShader.h" -#include <gfx/gl/glSource.h> -#include <gfx/gl/programHandle.h> +#include <gfx/gl/program.h> +#include <gfx/gl/shader.h> #include <gfx/gl/shaders/fs-uiShader.h> #include <gfx/gl/shaders/fs-uiShaderFont.h> #include <gfx/gl/shaders/vs-uiShader.h> @@ -8,30 +8,21 @@ #include <glm/gtc/type_ptr.hpp> #include <initializer_list> -UIShader::UIShader(size_t width, size_t height) : - progDefault {uiShader_vs.compile(), uiShader_fs.compile()}, progText {uiShader_vs.compile(), - uiShaderFont_fs.compile()} +UIShader::IconProgram::IconProgram(const glm::mat4 & vp) : UIProgram {vp, uiShader_vs, uiShader_fs} { } +UIShader::TextProgram::TextProgram(const glm::mat4 & vp) : + UIProgram {vp, uiShader_vs, uiShaderFont_fs}, colorLoc {*this, "colour"} { - for (const auto prog : {&progDefault, &progText}) { - if (auto loc = glGetUniformLocation(prog->m_program, "uiProjection"); loc >= 0) { - glUseProgram(prog->m_program); - const auto uiProjection = glm::ortho<float>(0, static_cast<float>(width), 0, static_cast<float>(height)); - glUniformMatrix4fv(loc, 1, GL_FALSE, glm::value_ptr(uiProjection)); - } - } } -void -UIShader::useDefault() const +UIShader::UIShader(size_t width, size_t height) : + UIShader {glm::ortho<float>(0, static_cast<float>(width), 0, static_cast<float>(height))} { - glUseProgram(progDefault.m_program); } +UIShader::UIShader(const glm::mat4 & viewProjection) : icon {viewProjection}, text {viewProjection} { } void -UIShader::useText(glm::vec3 colour) const +UIShader::TextProgram::use(const glm::vec3 & colour) const { - glUseProgram(progText.m_program); - if (auto loc = glGetUniformLocation(progText.m_program, "colour"); loc >= 0) { - glUniform3fv(loc, 1, glm::value_ptr(colour)); - } + Program::use(); + glUniform3fv(colorLoc, 1, glm::value_ptr(colour)); } |