Shader.h 825 B

123456789101112131415161718192021222324252627282930
  1. #ifndef SHADER_H
  2. #define SHADER_H
  3. #include <GL/glew.h>
  4. class Shader final {
  5. public:
  6. Shader(const GLchar* vPath, const GLchar* fPath);
  7. ~Shader();
  8. Shader(const Shader& other) = delete;
  9. Shader(Shader&& other) = delete;
  10. Shader& operator=(const Shader& other) = delete;
  11. Shader& operator=(Shader&& other) = delete;
  12. bool hasError() const;
  13. void use() const;
  14. void setMatrix(const GLchar* name, const GLfloat* data) const;
  15. void setInt(const GLchar* name, GLint data) const;
  16. private:
  17. bool readFileAndCompile(const GLchar* path, GLuint& shader, GLenum shaderType);
  18. bool readFile(GLchar* buffer, size_t bufferSize, const GLchar* path) const;
  19. bool compile(GLuint& shader, const GLchar* code, GLenum shaderType);
  20. GLuint vShader;
  21. GLuint fShader;
  22. GLuint program;
  23. };
  24. #endif