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/uiShader.h | |
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/uiShader.h')
-rw-r--r-- | gfx/gl/uiShader.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/gfx/gl/uiShader.h b/gfx/gl/uiShader.h index ea5bf25..ee44af7 100644 --- a/gfx/gl/uiShader.h +++ b/gfx/gl/uiShader.h @@ -1,19 +1,44 @@ #pragma once -#include "programHandle.h" +#include "program.h" #include <GL/glew.h> #include <cstddef> #include <glm/glm.hpp> +#include <glm/gtc/type_ptr.hpp> class UIShader { public: UIShader(std::size_t width, std::size_t height); - void useDefault() const; - void useText(glm::vec3) const; private: - class UIProgramHandle : public ProgramHandleBase { - using ProgramHandleBase::ProgramHandleBase; + explicit UIShader(const glm::mat4 & viewProjection); + + class UIProgram : public Program { + public: + template<typename... S> UIProgram(const glm::mat4 & vp, S &&... srcs) : Program {std::forward<S>(srcs)...} + { + RequiredUniformLocation uiProjectionLoc {*this, "uiProjection"}; + glUseProgram(*this); + glUniformMatrix4fv(uiProjectionLoc, 1, GL_FALSE, glm::value_ptr(vp)); + } + }; + + class IconProgram : public UIProgram { + public: + explicit IconProgram(const glm::mat4 & vp); + using Program::use; + }; + + class TextProgram : public UIProgram { + public: + explicit TextProgram(const glm::mat4 & vp); + void use(const glm::vec3 & colour) const; + + private: + RequiredUniformLocation colorLoc; }; - UIProgramHandle progDefault, progText; + +public: + IconProgram icon; + TextProgram text; }; |