shader.hpp 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // shader.hpp: Loads shaders into opengl
  2. #ifndef IS_SHADER_H_
  3. #define IS_SHADER_H_
  4. #include <string>
  5. #include <cstdio>
  6. #include <vector>
  7. #include <glm/glm.hpp>
  8. #include <glm/gtc/type_ptr.hpp>
  9. #include <GL/glew.h>
  10. #include <string>
  11. #include <fstream>
  12. #include <streambuf>
  13. namespace slop {
  14. class Shader {
  15. public:
  16. Shader( std::string name, std::string vert, std::string frag, std::string shadertype = "other" );
  17. ~Shader();
  18. unsigned int getProgram();
  19. std::string m_name;
  20. void bind();
  21. void unbind();
  22. void setParameter( std::string name, int foo );
  23. void setParameter( std::string name, float foo );
  24. void setParameter( std::string name, glm::mat4 foo );
  25. void setParameter( std::string name, glm::vec4 foo );
  26. void setParameter( std::string name, glm::vec2 foo );
  27. void setAttribute( std::string name, unsigned int buffer, unsigned int stepsize );
  28. int m_type;
  29. private:
  30. std::vector<unsigned int> m_activeattribs;
  31. bool m_good;
  32. unsigned int getUniformLocation( std::string );
  33. int compile( unsigned int shader );
  34. int link( unsigned int vert, unsigned int frag );
  35. unsigned int m_program;
  36. };
  37. };
  38. #endif // IS_SHADER_H_