diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-12 16:00:54 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-12 16:00:54 +0000 |
commit | 4e1e30a5e5edfe36410e3da095ad98e181a29ce9 (patch) | |
tree | 62eb60b33fd4ffe713cb624fd77f7ae68145e82e /gfx/gl | |
parent | Move GL shared source into it's own class/file (diff) | |
download | ilt-4e1e30a5e5edfe36410e3da095ad98e181a29ce9.tar.bz2 ilt-4e1e30a5e5edfe36410e3da095ad98e181a29ce9.tar.xz ilt-4e1e30a5e5edfe36410e3da095ad98e181a29ce9.zip |
Split 3D specifics of programs out of a base class
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/shader.cpp | 13 | ||||
-rw-r--r-- | gfx/gl/shader.h | 15 |
2 files changed, 18 insertions, 10 deletions
diff --git a/gfx/gl/shader.cpp b/gfx/gl/shader.cpp index 06edc5c..12ab510 100644 --- a/gfx/gl/shader.cpp +++ b/gfx/gl/shader.cpp @@ -16,20 +16,23 @@ #include <stdexcept>
#include <string>
-Shader::ProgramHandle::ProgramHandle(GLuint vs, GLuint fs) : viewProjection_uniform {}, model_uniform {}
+ProgramHandleBase::ProgramHandleBase(GLuint vs, GLuint fs) : viewProjection_uniform {}, model_uniform {}
{
glAttachShader(m_program, vs);
glAttachShader(m_program, fs);
- glBindAttribLocation(m_program, 0, "position");
- glBindAttribLocation(m_program, 1, "texCoord");
- glBindAttribLocation(m_program, 2, "normal");
-
glLinkProgram(m_program);
GLsource::CheckShaderError(m_program, GL_LINK_STATUS, true, "Error linking shader program");
glValidateProgram(m_program);
GLsource::CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "Invalid shader program");
+}
+
+Shader::ProgramHandle::ProgramHandle(GLuint vs, GLuint fs) : ProgramHandleBase {vs, fs}
+{
+ glBindAttribLocation(m_program, 0, "position");
+ glBindAttribLocation(m_program, 1, "texCoord");
+ glBindAttribLocation(m_program, 2, "normal");
viewProjection_uniform = glGetUniformLocation(m_program, "viewProjection");
model_uniform = glGetUniformLocation(m_program, "model");
diff --git a/gfx/gl/shader.h b/gfx/gl/shader.h index 3ee9449..5b3aab8 100644 --- a/gfx/gl/shader.h +++ b/gfx/gl/shader.h @@ -9,6 +9,15 @@ class Location;
+class ProgramHandleBase {
+public:
+ ProgramHandleBase(GLuint, GLuint);
+ using ProgramRef = glRef<GLuint, __glewCreateProgram, __glewDeleteProgram>;
+
+ ProgramRef m_program;
+ GLint viewProjection_uniform, model_uniform;
+};
+
class Shader {
public:
enum class Program { Basic = 0, Water = 1, LandMass = 2, StaticPos = 3 };
@@ -20,13 +29,9 @@ public: void setUniform(const GLchar *, glm::vec3 dir) const;
private:
- class ProgramHandle {
+ class ProgramHandle : public ProgramHandleBase {
public:
ProgramHandle(GLuint, GLuint);
- using ProgramRef = glRef<GLuint, __glewCreateProgram, __glewDeleteProgram>;
-
- ProgramRef m_program;
- GLint viewProjection_uniform, model_uniform;
};
std::array<ProgramHandle, 4> programs;
|