Face3d
ShaderLoader.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // Common
4 #include <string>
5 #include <map>
6 // Helpers
7 #include "GLHeader.hpp"
8 
9 namespace Face3D
10 {
13  {
14  public:
16  static ShaderLoader& Instance();
17 
19  GLuint getProgram(const std::string& shaderClassName);
20 
21  GLuint loadShader(const std::string& shaderClassName, GLenum shaderType);
22  void deleteShader(const GLuint shaderID);
23 
24  GLuint createProgram();
25  void linkProgram(const GLuint programID);
26  void attachShader(const GLuint programID, const GLuint shaderID);
27  void checkProgram(const GLuint programID);
28 
29  void addToCache(const GLuint programID, const std::string &shaderProgramName);
30 
31  private:
33  GLuint loadVertexAndFragmentShader(const std::string& shaderClassName);
34  std::string readInShaderCode(const std::string& pathToShaderFile);
35 
36  void compileShader(GLuint shaderID, const std::string &shaderCode);
37  void checkShader(GLuint shaderID, GLint result);
38 
39  std::map<std::string, GLuint> m_ShaderProgramMap;
40  };
41 }
static ShaderLoader & Instance()
get instance
Definition: ShaderLoader.cpp:13
GLuint createProgram()
Definition: ShaderLoader.cpp:73
void checkShader(GLuint shaderID, GLint result)
Definition: ShaderLoader.cpp:138
void linkProgram(const GLuint programID)
Definition: ShaderLoader.cpp:83
GLuint loadVertexAndFragmentShader(const std::string &shaderClassName)
Definition: ShaderLoader.cpp:107
std::map< std::string, GLuint > m_ShaderProgramMap
Definition: ShaderLoader.hpp:39
void deleteShader(const GLuint shaderID)
Definition: ShaderLoader.cpp:68
void attachShader(const GLuint programID, const GLuint shaderID)
Definition: ShaderLoader.cpp:78
void checkProgram(const GLuint programID)
Definition: ShaderLoader.cpp:89
void compileShader(GLuint shaderID, const std::string &shaderCode)
Definition: ShaderLoader.cpp:131
std::string readInShaderCode(const std::string &pathToShaderFile)
Definition: ShaderLoader.cpp:153
Definition: ShaderLoader.hpp:12
void addToCache(const GLuint programID, const std::string &shaderProgramName)
Definition: ShaderLoader.cpp:38
ShaderLoader()
Definition: ShaderLoader.hpp:32
GLuint loadShader(const std::string &shaderClassName, GLenum shaderType)
Definition: ShaderLoader.cpp:47
Definition: Common.hpp:7
GLuint getProgram(const std::string &shaderClassName)
get shader program
Definition: ShaderLoader.cpp:20