source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h @ 3038

Revision 3038, 2.7 KB checked in by mattausch, 16 years ago (diff)

unified shader stuff, but phreetham sky not working anymore for forward rendering

Line 
1#ifndef __ResourceManager_H__
2#define __ResourceManager_H__
3
4
5#include <string>
6#include <iostream>
7#include <fstream>
8#include <map>
9#include "common.h"
10
11
12
13class igzstream;
14
15
16namespace CHCDemoEngine
17{
18
19class SceneEntity;
20class Material;
21class Geometry;
22class Texture;
23class Matrix4x4;
24class Transform3;
25class ShaderProgram;
26class GPUProgramParameters;
27
28
29/** Loads a scene and also handles the cleanup
30*/
31class ResourceManager
32{
33public:
34
35        /** Returns the resource manager as a singleton.
36        */
37        static ResourceManager *GetSingleton()
38        {
39                if (!sResourceManager)
40                {
41                        sResourceManager = new ResourceManager();
42                }
43
44                return sResourceManager;
45        }
46
47        /** We also want full control over the delete.
48        */
49        static void DelSingleton()
50        {
51                DEL_PTR(sResourceManager);
52        }
53
54        /** Loads a model
55        */
56        bool Load(const std::string &filename, SceneEntityContainer &geometry);
57
58        int GetNumEntities() const { return (int)mSceneEntities.size(); }
59
60        /** Creates new gpu program parameters.
61        */
62        GPUProgramParameters *CreateGPUProgramParameters(ShaderProgram *p);
63        /** Creates a new shader program.
64        */
65        ShaderProgram *CreateFragmentProgram(const std::string &filename, const std::string &funcName);
66        ShaderProgram *CreateVertexProgram(const std::string &filename, const std::string &funcName);
67
68        void EnableFragmentProfile();
69        void EnableVertexProfile();
70
71        void DisableFragmentProfile();
72        void DisableVertexProfile();
73
74
75protected:
76       
77        /** Default constructor. The constructor is protected
78                to have control over instantiation using the
79                singleton pattern.
80        */
81        ResourceManager();
82
83        ~ResourceManager();
84
85
86        void InitCg();
87
88        void LoadTextures(igzstream &str);
89        void LoadShapes(igzstream &str);
90        void LoadSceneEntities(igzstream &str, SceneEntityContainer &entities);
91
92        SceneEntity *LoadSceneEntity(igzstream &str);
93        Material *LoadMaterial(igzstream &str);
94        Geometry *LoadGeometry(igzstream &str);
95
96        std::map<int, Texture *> mTextureTable;
97        std::map<int, Material *> mMaterialTable;
98        std::map<int, Geometry *> mGeometryTable;
99        //std::map<int, Shape *> mShapesTable;
100
101
102        /////////////
103        //-- these are kept to be able to delete these resources afterwards
104
105        TextureContainer mTextures;
106        MaterialContainer mMaterials;
107        GeometryContainer mGeometry;
108        TransformContainer mTrafos;
109        GPUParamContainer mGPUParameters;
110        ShaderContainer mShaders;
111        ShapeContainer mShapes;
112        LODContainer mLODs;
113
114        ////////
115
116        /// the scene entities
117
118        SceneEntityContainer mSceneEntities;
119
120
121        ////////////
122        //-- default shader programs
123
124        ShaderProgram *mMrtDefaultVertexProgram;
125        ShaderProgram *mMrtDefaultFragmentProgram;
126        ShaderProgram *mMrtDefaultFragmentTexProgram;
127
128
129private:
130
131        static ResourceManager *sResourceManager;
132};
133
134
135}
136#endif
Note: See TracBrowser for help on using the repository browser.