diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-12 16:07:41 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-12 16:07:41 +0000 |
commit | 6698c81d0628e917beb75f71383e3b3108b0804c (patch) | |
tree | 987fc520c7386831300e70e0ffeb466dbd38932e | |
parent | Split 3D specifics of programs out of a base class (diff) | |
download | ilt-6698c81d0628e917beb75f71383e3b3108b0804c.tar.bz2 ilt-6698c81d0628e917beb75f71383e3b3108b0804c.tar.xz ilt-6698c81d0628e917beb75f71383e3b3108b0804c.zip |
Move program handle to its own files
-rw-r--r-- | gfx/gl/programHandle.cpp | 14 | ||||
-rw-r--r-- | gfx/gl/programHandle.h | 16 | ||||
-rw-r--r-- | gfx/gl/shader.cpp | 12 | ||||
-rw-r--r-- | gfx/gl/shader.h | 10 |
4 files changed, 31 insertions, 21 deletions
diff --git a/gfx/gl/programHandle.cpp b/gfx/gl/programHandle.cpp new file mode 100644 index 0000000..bfe06f2 --- /dev/null +++ b/gfx/gl/programHandle.cpp @@ -0,0 +1,14 @@ +#include "programHandle.h" +#include "glSource.h" + +ProgramHandleBase::ProgramHandleBase(GLuint vs, GLuint fs) : viewProjection_uniform {}, model_uniform {} +{ + glAttachShader(m_program, vs); + glAttachShader(m_program, fs); + + 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"); +} diff --git a/gfx/gl/programHandle.h b/gfx/gl/programHandle.h new file mode 100644 index 0000000..6aa1084 --- /dev/null +++ b/gfx/gl/programHandle.h @@ -0,0 +1,16 @@ +#ifndef PROGRAM_HANDLE_H +#define PROGRAM_HANDLE_H + +#include <GL/glew.h> +#include <glRef.hpp> + +class ProgramHandleBase { +public: + ProgramHandleBase(GLuint, GLuint); + using ProgramRef = glRef<GLuint, __glewCreateProgram, __glewDeleteProgram>; + + ProgramRef m_program; + GLint viewProjection_uniform, model_uniform; +}; + +#endif diff --git a/gfx/gl/shader.cpp b/gfx/gl/shader.cpp index 12ab510..47e08c5 100644 --- a/gfx/gl/shader.cpp +++ b/gfx/gl/shader.cpp @@ -16,18 +16,6 @@ #include <stdexcept>
#include <string>
-ProgramHandleBase::ProgramHandleBase(GLuint vs, GLuint fs) : viewProjection_uniform {}, model_uniform {}
-{
- glAttachShader(m_program, vs);
- glAttachShader(m_program, fs);
-
- 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");
diff --git a/gfx/gl/shader.h b/gfx/gl/shader.h index 5b3aab8..249b2f4 100644 --- a/gfx/gl/shader.h +++ b/gfx/gl/shader.h @@ -1,6 +1,7 @@ #ifndef SHADER_INCLUDED_H
#define SHADER_INCLUDED_H
+#include "programHandle.h"
#include <GL/glew.h>
#include <array>
#include <glRef.hpp>
@@ -9,15 +10,6 @@ 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 };
|