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

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