source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.h @ 3057

Revision 3057, 1.8 KB checked in by mattausch, 16 years ago (diff)

added a shader manager

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