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

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