Masterchoc

Untitled

Jan 4th, 2018
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <vector>
  6. #include <string>
  7. #include <map>
  8.  
  9. #include <GL/glew.h>
  10.  
  11. #include "transform.h"
  12. #include "camera.h"
  13. #include "Light.h"
  14.  
  15. class Shader
  16. {
  17. public:
  18.     Shader(const std::string& filename);
  19.     virtual ~Shader();
  20.  
  21.     void bind();
  22.     void unbind();
  23.     void bindAttribute(GLuint location, const std::string& name);
  24.  
  25.     std::string loadShader(const std::string& filename);
  26.     void checkShaderError(GLuint shader, GLuint flag, bool isProgram, const std::string& message);
  27.     GLuint createShader(const std::string& text, GLenum type);
  28.  
  29.     void addUniform(const std::string& name);
  30.  
  31.     void setUniformMat4fv(const std::string& name, const glm::mat4& mat);
  32.     void setUniform3fv(const std::string& name, const glm::vec3& vec);
  33.  
  34. private:
  35.     static const unsigned int NUM_SHADERS = 2;
  36.  
  37.     enum {
  38.         TRANSFORM_U,
  39.         VIEW_U,
  40.         PROJ_U,
  41.         LIGHT_POSITION_U,
  42.         LIGHT_COLOR_U,
  43.         NUM_UNIFORMS
  44.     };
  45.  
  46.     GLuint m_program;
  47.     GLuint m_shaders[NUM_SHADERS];
  48.  
  49.     std::map<std::string, GLuint> m_uniforms;
  50. };
Add Comment
Please, Sign In to add comment