From c3eea71370eb94cff1fd96185458643fab6eb2c5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 3 Nov 2022 19:47:46 +0000 Subject: Restructure how shaders are worked with Needs a tidy-up --- gfx/gl/uiShader.h | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'gfx/gl/uiShader.h') 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 #include #include +#include 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 UIProgram(const glm::mat4 & vp, S &&... srcs) : Program {std::forward(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; }; -- cgit v1.2.3