Kinetic Visualization
 All Classes Functions Variables Pages
Shader.h
1 #pragma once
2 // system includes
3 #include <iostream>
4 #include <fstream>
5 
6 #include "GL/glew.h"
7 #include "GLM/glm.hpp"
8 
9 class Shader {
10 
11 public:
13  Shader();
15  ~Shader();
16 
21  void loadCompileAndLinkShader(char* vertexShaderLocation, char* geometryShaderLocation, char* fragmentShaderLoacation);
22 
27  void loadCompileAndLinkShader(char* vertexShaderLocation, char* fragmentShaderLoacation);
28 
29  // Define the name of the variable inside the shader which represents the final color for each fragment.
30  void bind_frag_data_location(const std::string &name)
31  {
32  if(shaderProgram > 0)
33  {
34  glBindFragDataLocation(shaderProgram, 0, name.c_str() );
35  link();
36  }
37  }
38 
39  // Define the name of the variable inside the shader which represents the final color for each fragment.
40  void bind_frag_data_location(const std::string &name, const std::string &name2)
41  {
42  if(shaderProgram > 0)
43  {
44  glBindFragDataLocation(shaderProgram, 0, name.c_str() );
45  glBindFragDataLocation(shaderProgram, 1, name2.c_str() );
46  link();
47  }
48  }
49 
51  GLint getShaderProgram() const;
52 
53 private:
55  GLint shaderProgram;
57  GLuint vertex_shader_handle;
59  GLuint fragment_shader_handle;
61  GLuint geometry_shader_handle;
62 
67  void loadAndCompile(char* vertexShaderLocation, char* fragmentShaderLoacation);
68 
73  void loadAndCompile(char* vertexShaderLocation, char* geometryShaderLocation, char* fragmentShaderLoacation);
74 
75 
77  void link();
78 };