summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/programHandle.cpp14
-rw-r--r--gfx/gl/programHandle.h16
-rw-r--r--gfx/gl/shader.cpp12
-rw-r--r--gfx/gl/shader.h10
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 };