From 43a87590f45aa6e55724d30d0c2d0d34b407a57e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 17 Jan 2021 18:54:26 +0000 Subject: First cut modernizing and sanitizing --- shader.h | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'shader.h') diff --git a/shader.h b/shader.h index bd3ac38..85a7d58 100644 --- a/shader.h +++ b/shader.h @@ -1,36 +1,33 @@ #ifndef SHADER_INCLUDED_H #define SHADER_INCLUDED_H -#include "transform.h" #include +#include #include +class Camera; +class Transform; + class Shader { public: - Shader(const std::string & fileName); - - void Bind(); - void Update(const Transform & transform, const Camera & camera); - + explicit Shader(const std::string & fileName); virtual ~Shader(); + void operator=(const Shader &) = delete; + Shader(const Shader &) = delete; + + void Bind() const; + void Update(const Transform & transform, const Camera & camera) const; -protected: private: - static const unsigned int NUM_SHADERS = 2; - static const unsigned int NUM_UNIFORMS = 3; - void - operator=(const Shader & shader) - { - } - Shader(const Shader & shader) { } - - std::string LoadShader(const std::string & fileName); - void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, const std::string & errorMessage); - GLuint CreateShader(const std::string & text, unsigned int type); + static constexpr unsigned int NUM_SHADERS = 2; + static constexpr unsigned int NUM_UNIFORMS = 3; + + static void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, const std::string & errorMessage); + static GLuint CreateShader(const GLchar * text, GLint len, unsigned int type); GLuint m_program; - GLuint m_shaders[NUM_SHADERS]; - GLuint m_uniforms[NUM_UNIFORMS]; + std::array m_shaders; + std::array m_uniforms; }; #endif -- cgit v1.2.3