1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef SHADER_H
- #define SHADER_H
- #include "math/Vector.h"
- #include "utils/List.h"
- #include "wrapper/GL.h"
- class Shader final {
- GL::Shader vertexShader;
- GL::Shader geometryShader;
- GL::Shader fragmentShader;
- GL::Program program;
- public:
- Shader(const char* vertexPath, const char* fragmentPath,
- const char* geometryPath = nullptr);
- ~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 char* name, const float* data);
- void setInt(const char* name, int data);
- void setFloat(const char* name, float data);
- void setVector(const char* name, const Vector2& v);
- void setVector(const char* name, const Vector3& v);
- void setVector(const char* name, const Vector4& v);
- private:
- void clean();
- bool compile(const char* path, GL::Shader& s, GL::ShaderType st);
- bool readFile(List<char>& code, const char* path) const;
- bool compile(GL::Shader& s, const List<char>& code, GL::ShaderType st);
- };
- #endif
|