From 60072c1d8089ffd3294e76636198d14710be95b8 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 9 Sep 2017 07:55:22 +0100 Subject: Restructuring --- yage/base/glslprogram.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 yage/base/glslprogram.h (limited to 'yage/base/glslprogram.h') diff --git a/yage/base/glslprogram.h b/yage/base/glslprogram.h new file mode 100644 index 00000000..fbe5ac5c --- /dev/null +++ b/yage/base/glslprogram.h @@ -0,0 +1,52 @@ +/* ---------------------------------------------------------------------------- + * glslprogram.h + * + * Copyright (c) 2017 Yann Herklotz Grave -- MIT License + * See file LICENSE for more details + * ---------------------------------------------------------------------------- + */ + +#ifndef GLSL_PROGRAM_H +#define GLSL_PROGRAM_H + +#include + +#include + +namespace yage +{ + +class GlslProgram +{ +private: + /// compiled shader program id + GLuint program_id_ = 0; + GLuint vertex_shader_id_ = 0; + GLuint fragment_shader_id_ = 0; + int attribute_index_ = 0; + + /// compiles one shader + void compileShader(const GLuint &shader, const std::string &file_path); + +public: + GlslProgram() = default; + GlslProgram(const GlslProgram &) = delete; + GlslProgram(GlslProgram &&) = delete; + ~GlslProgram(); + + GlslProgram &operator=(const GlslProgram &) = delete; + GlslProgram &operator=(GlslProgram &&) = delete; + + /// compiles vertex and fragment shader + void compileShaders(const std::string &vertex_shader_path, + const std::string &fragment_shader_path); + void linkShaders(); + void addAttribute(const std::string &attribute_name); + GLint getUniformLocation(const std::string &uniform_name); + void use(); + void unuse(); +}; + +} // namespace yage + +#endif -- cgit