Shader.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef SHADER_H
  2. #define SHADER_H
  3. #include "math/Vector.h"
  4. #include "utils/List.h"
  5. #include "wrapper/GL.h"
  6. class Shader final {
  7. GL::Shader vertexShader;
  8. GL::Shader geometryShader;
  9. GL::Shader fragmentShader;
  10. GL::Program program;
  11. public:
  12. Shader(const char* vertexPath, const char* fragmentPath,
  13. const char* geometryPath = nullptr);
  14. ~Shader();
  15. Shader(const Shader& other) = delete;
  16. Shader(Shader&& other) = delete;
  17. Shader& operator=(const Shader& other) = delete;
  18. Shader& operator=(Shader&& other) = delete;
  19. bool hasError() const;
  20. void use() const;
  21. void setMatrix(const char* name, const float* data);
  22. void setInt(const char* name, int data);
  23. void setFloat(const char* name, float data);
  24. void setVector(const char* name, const Vector2& v);
  25. void setVector(const char* name, const Vector3& v);
  26. void setVector(const char* name, const Vector4& v);
  27. private:
  28. void clean();
  29. bool compile(const char* path, GL::Shader& s, GL::ShaderType st);
  30. bool readFile(List<char>& code, const char* path) const;
  31. bool compile(GL::Shader& s, const List<char>& code, GL::ShaderType st);
  32. };
  33. #endif