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

Revision 3054, 3.0 KB checked in by mattausch, 16 years ago (diff)

worked on render queue

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