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 }
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
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
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 }
00170
00171 #endif