shader.hpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef N_SHADER_H_
  2. #define N_SHADER_H_
  3. #include <fstream>
  4. #include <vector>
  5. #include <string>
  6. #include <exception>
  7. #include "gl_core_3_3.h"
  8. #include <glm/glm.hpp>
  9. #include <glm/gtc/type_ptr.hpp>
  10. #include <EGL/egl.h>
  11. #include <GL/gl.h>
  12. #include "resource.hpp"
  13. class Shader {
  14. public:
  15. Shader( std::string vert, std::string frag );
  16. ~Shader();
  17. unsigned int getProgram();
  18. void bind();
  19. void unbind();
  20. void setParameter( std::string name, int foo );
  21. void setParameter( std::string name, float foo );
  22. void setParameter( std::string name, glm::mat4& foo );
  23. void setParameter( std::string name, glm::vec4 foo );
  24. void setParameter( std::string name, glm::vec2 foo );
  25. void setAttribute( std::string name, unsigned int buffer, unsigned int stepsize );
  26. private:
  27. std::vector<unsigned int> m_activeattribs;
  28. bool m_good;
  29. unsigned int getUniformLocation( std::string );
  30. int compile( unsigned int shader, std::string& error );
  31. int link( unsigned int vert, unsigned int frag, std::string& error );
  32. unsigned int m_program;
  33. };
  34. #endif // N_SHADER_H_