ShaderProgram.h 717 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef SHADERPROGRAM_H
  2. #define SHADERPROGRAM_H
  3. #include <GL/glew.h>
  4. #include <GLFW/glfw3.h>
  5. #include <iostream>
  6. using namespace std;
  7. class ShaderProgram
  8. {
  9. public:
  10. ShaderProgram();
  11. virtual ~ShaderProgram();
  12. void compile(const GLchar* vertexPath, const GLchar* fragmentPath);
  13. bool isValid() const;
  14. GLuint getProgram() const;
  15. private:
  16. GLchar* readFile(const GLchar* name);
  17. bool checkShaderErrors(const GLchar* name, GLuint shader);
  18. void compile(const GLchar* vertexPath, const GLchar* vertexData, const GLchar* fragmentPath, const GLchar* fragmentData);
  19. GLuint vertexShader = 0;
  20. GLuint fragmentShader = 0;
  21. GLuint program = 0;
  22. bool valid = false;
  23. };
  24. #endif