1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef SHADER_H
- #define SHADER_H
- #include <GL/glew.h>
- #include "math/Vector.h"
- #include "utils/Array.h"
- class Shader final {
- GLuint vertexShader;
- GLuint fragmentShader;
- GLuint program;
- public:
- Shader(const char* vertexPath, const char* fragmentPath);
- ~Shader();
- Shader(const Shader& other) = delete;
- Shader(Shader&& other) = delete;
- Shader& operator=(const Shader& other) = delete;
- Shader& operator=(Shader&& other) = delete;
- bool hasError() const;
- void use() const;
- void setMatrix(const GLchar* name, const GLfloat* data);
- void setInt(const GLchar* name, GLint data);
- void setFloat(const GLchar* name, GLfloat data);
- void setVector(const GLchar* name, const Vector2& v);
- void setVector(const GLchar* name, const Vector3& v);
- void setVector(const GLchar* name, const Vector4& v);
- private:
- typedef Array<GLchar, 1024 * 128> Code;
- typedef Array<GLchar, 1024> ErrorLog;
- bool readFileAndCompile(const char* path, GLuint& shader, GLenum shaderType);
- bool readFile(Code& code, const char* path) const;
- bool compile(GLuint& shader, const Code& code, GLenum shaderType);
- };
- #endif
|