random_racer/src/ResourceManager.h

Go to the documentation of this file.
00001 #ifndef _RR_RESOURCEMANAGER_H_
00002 #define _RR_RESOURCEMANAGER_H_
00003 
00004 #include <stdio.h>
00005 
00006 #include <vrs/container/dictionary.h>
00007 #include <vrs/font.h>
00008 #include <vrs/sharedobj.h>
00009 
00010 namespace VRS
00011 {
00012 class Image;
00013 class ImageTexture2DGL;
00014 class ImageCubeMapTextureGL;
00015 class SceneThing;
00016 } // namespace VRS
00017 
00018 
00019 namespace random_racer
00020 {
00026 class ResourceManager : public VRS::SharedObj
00027 {
00031     static VRS::SO<ResourceManager> s_instance;
00032     
00036     ResourceManager();
00037     
00041     virtual ~ResourceManager();
00042     
00046     std::string m_fileDir;
00047     
00054     std::string m_homeDir;
00055     
00060     enum ResourceType {ImageType, TextureType, FontType, CubeType};
00061     
00066     struct ResourceContainer
00067     {
00068         ResourceType type;
00069         VRS::SO<VRS::SharedObj> sharedObject;
00070     };
00071     
00075     VRS::NonPersistentDictionary<std::string, ResourceContainer> 
00076         m_resourceRegistry;
00077     
00078 public:
00079     
00084     void setArgv(const std::string& argv);
00085     
00090     static VRS::SO<ResourceManager> get();
00091     
00096     VRS::SO<VRS::Image> loadImage(const std::string& imageName);
00097          
00106     VRS::SO<VRS::ImageTexture2DGL> loadTexture2D(const std::string& imageName,  
00107                                                  bool pow2, bool noException);
00108      
00113     VRS::SO<VRS::Font> loadFont(const std::string& fontName, VRS::Font::FontType 
00114                                                 fontType = VRS::Font::POLYGON);  
00115     
00122     VRS::SO<VRS::ImageCubeMapTextureGL> loadCubeTexture(
00123                     const std::string& imageName, const std::string& format);
00124     
00128      std::string getPathOfFile(const std::string& fileName);
00129     
00135     // TODO: move this to the Car class 
00136     //  Scene Graph for the 3ds File:
00137     //  Car
00138     //  |_ Chassis
00139     //  |  |_ Material
00140     //  |  |_ Texture
00141     //  |  |_ Mesh
00142     //  |  |_ ...
00143     //  |
00144     //  |_ Wheel_FL
00145     //  |  |_ ...
00146     //  |
00147     //  |_ Wheel_FR
00148     //  |_ Wheel_RL
00149     //  |_ Wheel_RR 
00150     //  |
00151     //  .
00152     //  .
00153     //  .
00154     //    
00155     VRS::SO<VRS::SceneThing> load3ds(const std::string& fileName);
00156     
00161     bool freeResource(const std::string& name);
00162      
00166     void freeAllResources();
00167 };
00168     
00169 } // namespace random_racer
00170 
00171 #endif /* _RR_RESOURCEMANAGER_H_ */

Generated on Fri May 11 21:01:58 2007 for Random Racer by  doxygen 1.5.1