You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shader.h 938B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Loads and manages a shader
  3. */
  4. #pragma once
  5. #include <GL/glew.h>
  6. #include <GL/gl.h>
  7. #include <string>
  8. #include <glm/mat4x4.hpp>
  9. #include <glm/vec4.hpp>
  10. #include <glm/vec3.hpp>
  11. namespace vtk {
  12. //forward declaration
  13. class ShaderUniform;
  14. class Shader {
  15. public:
  16. Shader();
  17. bool activate(); //Must be called to use shader
  18. //Load shader, type 0 = Vert, 1 = Frag, 2 = Geometry
  19. bool loadShaderFiles(const std::string& vertShader,
  20. const std::string& fragShader,
  21. const std::string& geomShader = "");
  22. GLuint loadShader(const std::string& code, const GLenum& shaderType);
  23. ShaderUniform getUniform(const std::string& name);
  24. protected:
  25. GLuint mShaderID;
  26. };
  27. //uniform setter
  28. class ShaderUniform {
  29. public:
  30. ShaderUniform(const GLint& uniformID);
  31. void set(const glm::mat4& data);
  32. void set(const glm::vec4& data);
  33. void set(const glm::vec3& data);
  34. protected:
  35. GLint mUniformID;
  36. };
  37. }