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

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;
26class GPUProgramParameters;
[2747]27
[2840]28
[2795]29/** Loads a scene and also handles the cleanup
30*/
31class ResourceManager
[2747]32{
33public:
34
[3037]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
[2795]54        /** Loads a model
55        */
[2755]56        bool Load(const std::string &filename, SceneEntityContainer &geometry);
[2747]57
[2948]58        int GetNumEntities() const { return (int)mSceneEntities.size(); }
59
[3036]60        /** Creates new gpu program parameters.
61        */
62        GPUProgramParameters *CreateGPUProgramParameters(ShaderProgram *p);
[3037]63        /** Creates a new shader program.
64        */
[3038]65        ShaderProgram *CreateFragmentProgram(const std::string &filename, const std::string &funcName);
66        ShaderProgram *CreateVertexProgram(const std::string &filename, const std::string &funcName);
[3036]67
[3038]68        void EnableFragmentProfile();
69        void EnableVertexProfile();
70
71        void DisableFragmentProfile();
72        void DisableVertexProfile();
73
74
[2747]75protected:
[2755]76       
[3037]77        /** Default constructor. The constructor is protected
78                to have control over instantiation using the
79                singleton pattern.
80        */
[3038]81        ResourceManager();
[3037]82
83        ~ResourceManager();
84
[3038]85
86        void InitCg();
87
[2795]88        void LoadTextures(igzstream &str);
89        void LoadShapes(igzstream &str);
90        void LoadSceneEntities(igzstream &str, SceneEntityContainer &entities);
[2757]91
[2795]92        SceneEntity *LoadSceneEntity(igzstream &str);
93        Material *LoadMaterial(igzstream &str);
94        Geometry *LoadGeometry(igzstream &str);
[2747]95
[2757]96        std::map<int, Texture *> mTextureTable;
[2764]97        std::map<int, Material *> mMaterialTable;
98        std::map<int, Geometry *> mGeometryTable;
[2842]99        //std::map<int, Shape *> mShapesTable;
[2795]100
[3038]101
102        /////////////
103        //-- these are kept to be able to delete these resources afterwards
104
[3036]105        TextureContainer mTextures;
106        MaterialContainer mMaterials;
107        GeometryContainer mGeometry;
108        TransformContainer mTrafos;
109        GPUParamContainer mGPUParameters;
[3038]110        ShaderContainer mShaders;
[2842]111        ShapeContainer mShapes;
[3019]112        LODContainer mLODs;
[2981]113
[2946]114        ////////
115
[2948]116        /// the scene entities
[3038]117
[2946]118        SceneEntityContainer mSceneEntities;
[3037]119
[3038]120
121        ////////////
122        //-- default shader programs
123
124        ShaderProgram *mMrtDefaultVertexProgram;
125        ShaderProgram *mMrtDefaultFragmentProgram;
126        ShaderProgram *mMrtDefaultFragmentTexProgram;
127
128
[3037]129private:
130
131        static ResourceManager *sResourceManager;
[2747]132};
133
[3037]134
[2755]135}
[2747]136#endif
Note: See TracBrowser for help on using the repository browser.