00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LILITH_RESOURCE_POOL
00024 #define LILITH_RESOURCE_POOL
00025
00026 #include "texture.h"
00027 #include "meshresource.h"
00028 #include "shader.h"
00029
00030 namespace lilith3d
00031 {
00032
00053 class ResourcePool
00054 {
00055 public:
00056 TextureManager textureManager;
00057 MeshResManager meshManager;
00058 ShaderManager shaderManager;
00059
00060 static ResourcePool* Instance() { return instance; }
00061
00062 ResourcePool() { GLASSERT( !instance );
00063 instance = this;
00064 }
00065 ~ResourcePool() { instance = 0; }
00066
00068 void SetImportPath( const std::string& path )
00069 {
00070 textureManager.SetImportPath( path );
00071 meshManager.SetImportPath( path );
00072 shaderManager.SetImportPath( path );
00073 }
00074
00076 bool LoadRequiredAssets()
00077 {
00078 return textureManager.LoadRequiredTextures()
00079 && meshManager.LoadRequiredModels()
00080 && shaderManager.LoadRequiredShaders();
00081 }
00082
00089 const Texture* LoadTexture( const std::string& filename,
00090 const std::string& textureName,
00091 int textureId = 0,
00092 int flags = 0 )
00093 {
00094 return textureManager.LoadTexture( filename, textureName, textureId, flags );
00095 }
00096
00101 const Texture* GetTexture( const std::string& textureName, U32 textureId )
00102 {
00103 return textureManager.GetTexture( textureName, textureId );
00104 }
00105
00112 StaticResource* LoadStaticRes( const std::string& filename, const std::string& name, U32 flags )
00113 {
00114 return meshManager.LoadStaticRes( filename, name, flags );
00115 }
00116
00124 MD2Resource* LoadMD2Res( const std::string& name,
00125 const std::string& md2MeshFilename,
00126 const std::string& skinTextureFilename,
00127 const std::string& md2WeaponFilename,
00128 const std::string& weaponTextureFilename )
00129 {
00130 return meshManager.LoadMD2ResComplete( name, md2MeshFilename, skinTextureFilename, md2WeaponFilename, weaponTextureFilename );
00131 }
00132
00134 const StaticResource* GetStaticRes( const std::string& name )
00135 {
00136 return meshManager.GetStaticRes( name );
00137 }
00138
00140 const MD2Resource* GetMD2Res( const std::string& name )
00141 {
00142 return meshManager.GetMD2Res( name );
00143 }
00144
00145 private:
00146 static ResourcePool* instance;
00147
00148 };
00149
00150 };
00151 #endif