break render apart into multiple files

This commit is contained in:
2020-03-10 14:11:13 -04:00
parent b504e5b7c3
commit d29fc033df
10 changed files with 452 additions and 487 deletions

View File

@@ -0,0 +1,46 @@
#pragma once
#include <string>
#include <utility>
#include <glad/glad.h>
#include <cgl/error.hpp>
#include <cgl/shader.hpp>
#include <cgl/program.hpp>
#include <util.hpp>
namespace cgl{
template<GLenum mode>
class shaderprogram : public program {
public:
shaderprogram() : program() {
glProgramParameteri(id, GL_PROGRAM_SEPARABLE, GL_TRUE);
}
shaderprogram(const std::string &src) : shaderprogram() {
shader<mode> sh(src);
attach(sh);
if (!link())
throw shader_error(get_info_log());
detach(sh);
}
static shaderprogram<mode> file(const std::string &name) {
return shaderprogram<mode>(utilReadFile(name));
}
};
namespace pgm {
using vert = shaderprogram<GL_VERTEX_SHADER>;
using tcs = shaderprogram<GL_TESS_CONTROL_SHADER>;
using tes = shaderprogram<GL_TESS_EVALUATION_SHADER>;
using geom = shaderprogram<GL_GEOMETRY_SHADER>;
using frag = shaderprogram<GL_FRAGMENT_SHADER>;
using comp = shaderprogram<GL_COMPUTE_SHADER>;
}
}