-
Notifications
You must be signed in to change notification settings - Fork 2
/
ShaderManager.h
66 lines (52 loc) · 1.73 KB
/
ShaderManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* File: ShaderManager.h
* Author: dude719
*
* Created on April 19, 2015, 6:58 AM
*/
#ifndef SHADERMANAGER_H
#define SHADERMANAGER_H
#include <string>
#include <map>
#include <fstream>
#include <sstream>
// Forward declaration
class Shader;
class ShaderManager
{
public:
~ShaderManager();
// Get the unique instance of this class
static ShaderManager* GetInstance();
/**
* Get shader object pointer
* @return if successful load/link, the loaded/linked shader object point is return, otherwise return the default shader
*/
Shader* GetShader(const char* inName, bool geomShader = false);
private:
// Default constructor (private)
ShaderManager();
/**
* Load, compile and create a vertex/fragment/geometric shader program and link the program
* @return CShader object pointer if all shaders are loaded successfully, NULL otherwise
*/
Shader* Load(const char* inVertexFilename, const char* inFragmentFilename, const char* inGeometryFilename);
/** Releases all resources */
void Dispose(Shader* inShader);
/**
* Load and compile a shader
* @param inShaderType type of shader: GL_VERTEX_SHADER, GL_GEOMETRY_SHADER_EXT or GL_FRAGMENT_SHADER
* @param inFileName shader file name
* @param inOutShader the pointer to shader
* @return true if successfully loaded, false otherwise
*/
bool LoadShader(unsigned int inShaderType, const std::string& inFileName, unsigned int & inOutShader);
private:
// Map of shader name and shader obj pointer
std::map<std::string, Shader*> m_shaderMap;
// Default shader string
static const char* DEFAULT_SHADER;
// The unique instance of this class
static ShaderManager* s_instance;
};
#endif /* SHADERMANAGER_H */