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/sceneShader.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/sceneShader.h')
-rw-r--r-- | gfx/gl/sceneShader.h | 81 |
1 files changed, 54 insertions, 27 deletions
diff --git a/gfx/gl/sceneShader.h b/gfx/gl/sceneShader.h index 61c159b..a85e55b 100644 --- a/gfx/gl/sceneShader.h +++ b/gfx/gl/sceneShader.h @@ -1,27 +1,54 @@ -#pragma once
-
-#include "programHandle.h"
-#include <GL/glew.h>
-#include <array>
-#include <glm/glm.hpp>
-
-class Location;
-
-class SceneShader {
-public:
- enum class Program { Basic = 0, Water = 1, LandMass = 2, StaticPos = 3 };
-
- SceneShader();
-
- void setView(glm::mat4 view) const;
- void setModel(const Location &, Program = Program::Basic) const;
- void setUniform(const GLchar *, glm::vec3 dir) const;
-
-private:
- class ProgramHandle : public ProgramHandleBase {
- public:
- ProgramHandle(GLuint, GLuint);
- };
-
- std::array<ProgramHandle, 4> programs;
-};
+#pragma once + +#include "program.h" + +class Location; + +struct SceneShader { + class SceneProgram : public Program { + public: + template<typename... S> + inline SceneProgram(const S &... srcs) : Program {srcs...}, viewProjectionLoc {*this, "viewProjection"} + { + } + + void setView(const glm::mat4 &) const; + + private: + RequiredUniformLocation viewProjectionLoc; + }; + + class BasicProgram : public SceneProgram { + public: + BasicProgram(); + void setModel(const Location &) const; + void use(const Location &) const; + + private: + RequiredUniformLocation modelLoc; + }; + + class AbsolutePosProgram : public SceneProgram { + public: + using Program::use; + using SceneProgram::SceneProgram; + }; + + class WaterProgram : public SceneProgram { + public: + public: + WaterProgram(); + void use(float waveCycle) const; + + private: + RequiredUniformLocation waveLoc; + }; + + SceneShader(); + + BasicProgram basic; + WaterProgram water; + AbsolutePosProgram landmass, absolute; + + void setView(glm::mat4 proj) const; +}; |