Shader.h 884 B

12345678910111213141516171819202122232425262728293031
  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. void setFloat(const GLchar* name, GLfloat data) const;
  17. private:
  18. bool readFileAndCompile(const GLchar* path, GLuint& shader, GLenum shaderType);
  19. bool readFile(GLchar* buffer, size_t bufferSize, const GLchar* path) const;
  20. bool compile(GLuint& shader, const GLchar* code, GLenum shaderType);
  21. GLuint vShader;
  22. GLuint fShader;
  23. GLuint program;
  24. };
  25. #endif