From 4e1e30a5e5edfe36410e3da095ad98e181a29ce9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 12 Dec 2021 16:00:54 +0000 Subject: Split 3D specifics of programs out of a base class --- gfx/gl/shader.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'gfx/gl/shader.cpp') 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 #include -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"); -- cgit v1.2.3