resourcepool.h

00001 /*--License:
00002         Lilith 3D Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2002-2007
00004         www.grinninglizard.com/lilith
00005 
00006         This program is free software; you can redistribute it and/or
00007         modify it under the terms of the GNU General Public License
00008         as published by the Free Software Foundation; either version 2
00009         of the License, or (at your option) any later version.
00010 
00011         This program is distributed in the hope that it will be useful,
00012         but WITHOUT ANY WARRANTY; without even the implied warranty of
00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014         GNU General Public License for more details.
00015 
00016         You should have received a copy of the GNU General Public License
00017         along with this program; if not, write to the Free Software
00018         Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020         The full text of the license can be found in license.txt
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 };      // lilith3d
00151 #endif

Generated on Fri Mar 23 19:36:22 2007 for Lilith3D by  doxygen 1.5.1-p1