1 | #ifndef __SHADERMANAGER_H__
|
---|
2 | #define __SHADERMANAGER_H__
|
---|
3 |
|
---|
4 |
|
---|
5 | #include <string>
|
---|
6 | #include <iostream>
|
---|
7 | #include <fstream>
|
---|
8 | #include <map>
|
---|
9 | #include "common.h"
|
---|
10 |
|
---|
11 | namespace CHCDemoEngine
|
---|
12 | {
|
---|
13 |
|
---|
14 | class Matrix4x4;
|
---|
15 | class Transform3;
|
---|
16 | class ShaderProgram;
|
---|
17 |
|
---|
18 | typedef std::map<std::string, ShaderProgram *> ShaderMap;
|
---|
19 |
|
---|
20 |
|
---|
21 | /** Loads a scene and also handles the cleanup
|
---|
22 | */
|
---|
23 | class ShaderManager
|
---|
24 | {
|
---|
25 | public:
|
---|
26 |
|
---|
27 | /** Returns the resource manager as a singleton.
|
---|
28 | */
|
---|
29 | inline static ShaderManager *GetSingleton();
|
---|
30 | /** We also want full control over the delete.
|
---|
31 | */
|
---|
32 | static void DelSingleton();
|
---|
33 | /** Creates a new shader program.
|
---|
34 | */
|
---|
35 | ShaderProgram *CreateFragmentProgram(const std::string &filename,
|
---|
36 | const std::string &funcName,
|
---|
37 | const std::string &name);
|
---|
38 |
|
---|
39 | ShaderProgram *CreateVertexProgram(const std::string &filename,
|
---|
40 | const std::string &funcName,
|
---|
41 | const std::string &name);
|
---|
42 |
|
---|
43 | void EnableFragmentProfile();
|
---|
44 | void EnableVertexProfile();
|
---|
45 |
|
---|
46 | void DisableFragmentProfile();
|
---|
47 | void DisableVertexProfile();
|
---|
48 |
|
---|
49 | ShaderProgram *GetShaderProgram(const std::string &name);
|
---|
50 |
|
---|
51 |
|
---|
52 | protected:
|
---|
53 |
|
---|
54 | /** Default constructor. The constructor is protected
|
---|
55 | to have control over instantiation using the
|
---|
56 | singleton pattern.
|
---|
57 | */
|
---|
58 | ShaderManager();
|
---|
59 |
|
---|
60 | ~ShaderManager();
|
---|
61 |
|
---|
62 | ShaderProgram *CreateShaderProgram(const std::string &filename,
|
---|
63 | const std::string &funcName,
|
---|
64 | const std::string &name,
|
---|
65 | bool isFragment);
|
---|
66 |
|
---|
67 | ////////////////////////
|
---|
68 |
|
---|
69 | ShaderContainer mShaders;
|
---|
70 | ShaderMap mShaderMap;
|
---|
71 |
|
---|
72 | private:
|
---|
73 |
|
---|
74 | static ShaderManager *sShaderManager;
|
---|
75 | };
|
---|
76 |
|
---|
77 |
|
---|
78 | ShaderManager *ShaderManager::GetSingleton()
|
---|
79 | {
|
---|
80 | if (!sShaderManager)
|
---|
81 | {
|
---|
82 | sShaderManager = new ShaderManager();
|
---|
83 | }
|
---|
84 |
|
---|
85 | return sShaderManager;
|
---|
86 | }
|
---|
87 |
|
---|
88 | }
|
---|
89 | #endif
|
---|