summaryrefslogtreecommitdiff
path: root/shader.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-17 18:54:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-01-17 18:54:26 +0000
commit43a87590f45aa6e55724d30d0c2d0d34b407a57e (patch)
tree21ce8e8886f8aa58b159419b7d885f57d9a37580 /shader.h
parentInitial commit (diff)
downloadilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.tar.bz2
ilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.tar.xz
ilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.zip
First cut modernizing and sanitizing
Diffstat (limited to 'shader.h')
-rw-r--r--shader.h37
1 files changed, 17 insertions, 20 deletions
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 <GL/glew.h>
+#include <array>
#include <string>
+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<GLuint, NUM_SHADERS> m_shaders;
+ std::array<GLint, NUM_UNIFORMS> m_uniforms;
};
#endif