SuzanneIsland: An island of Real-time rendering effects!
shader.h
1 #pragma once
2 
3 #include <string>
4 #include <iostream>
5 #include <fstream>
6 #include <map>
7 
8 #include <GL/glew.h>
9 #include <GLFW/glfw3.h>
10 
11 
15 class Shader
16 {
17 public:
18 
19  Shader(const std::string& vertexShader, const std::string& fragmentShader);
20  ~Shader();
21 
22  GLuint programHandle;
23 
26  void useShader() const;
27 
31  GLint getUniformLocation(const std::string& name);
32 
33 private:
34 
35  // gl shader uniform locations cached by name
36  std::map<std::string, GLint> uniforms;
37 
38  GLuint vertexHandle;
39  GLuint fragmentHandle;
40 
42  void loadShader(
43  const std::string& shader,
44  GLenum shaderType,
45  GLuint& handle
46  );
47 
49  void linkShaders();
50 
51 };
52 
void useShader() const
Set this as the active shader program.
Definition: shader.cpp:71
Shader class.
Definition: shader.h:15
GLint getUniformLocation(const std::string &name)
Return location of shader uniform if value not yet cached it is retrieved via glGetUniformLocation gl...
Definition: shader.cpp:76