Shader.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef SHADER_H
  2. #define SHADER_H
  3. #include "math/Vector.h"
  4. #include "utils/Error.h"
  5. #include "utils/List.h"
  6. #include "wrapper/GL.h"
  7. class Shader final {
  8. GL::Shader vertex;
  9. GL::Shader geometry;
  10. GL::Shader fragment;
  11. GL::Program program;
  12. public:
  13. Shader();
  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. Error compile(const char* vertexPath, const char* geometryPath,
  20. const char* fragmentPath);
  21. void use() const;
  22. void setMatrix(const char* name, const float* data);
  23. void setInt(const char* name, int data);
  24. void setFloat(const char* name, float data);
  25. void setVector(const char* name, const Vector2& v);
  26. void setVector(const char* name, const Vector3& v);
  27. void setVector(const char* name, const Vector4& v);
  28. private:
  29. Error compile(const char* path, GL::Shader& s, GL::ShaderType st);
  30. Error readFile(List<char>& code, const char* path) const;
  31. Error compile(GL::Shader& s, const List<char>& code, GL::ShaderType st);
  32. };
  33. #endif