00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreD3D9TextureManager.h" 00026 #include "OgreD3D9Texture.h" 00027 #include "OgreException.h" 00028 00029 namespace Ogre 00030 { 00031 D3D9TextureManager::D3D9TextureManager( LPDIRECT3DDEVICE9 pD3DDevice ) : TextureManager() 00032 { 00033 mpD3DDevice = pD3DDevice; 00034 if( !mpD3DDevice ) 00035 Except( Exception::ERR_INVALIDPARAMS, "Invalid Direct3DDevice passed", "D3D9TextureManager::D3D9TextureManager" ); 00036 } 00037 00038 D3D9TextureManager::~D3D9TextureManager() 00039 { 00040 this->unloadAndDestroyAll(); 00041 } 00042 00043 Texture *D3D9TextureManager::create( const String& name, TextureType texType ) 00044 { 00045 D3D9Texture *t = new D3D9Texture( name, texType, mpD3DDevice, TU_DEFAULT ); 00046 t->enable32Bit( mIs32Bit ); 00047 return t; 00048 } 00049 00050 Texture *D3D9TextureManager::createAsRenderTarget( const String& name ) 00051 { 00052 D3D9Texture *newTex = new D3D9Texture( name, TEX_TYPE_2D, mpD3DDevice, TU_RENDERTARGET ); 00053 newTex->enable32Bit( mIs32Bit ); 00054 newTex->load(); 00055 return newTex; 00056 } 00057 00058 Texture *D3D9TextureManager::createManual( 00059 const String & name, 00060 TextureType texType, 00061 uint width, 00062 uint height, 00063 uint num_mips, 00064 PixelFormat format, 00065 TextureUsage usage ) 00066 { 00067 return new D3D9Texture( name, texType, mpD3DDevice, width, height, num_mips, format, usage ); 00068 } 00069 00070 void D3D9TextureManager::unloadAndDestroyAll() 00071 { 00072 // Unload & delete resources in turn 00073 for( ResourceMap::iterator i = mResources.begin(); i != mResources.end(); i++ ) 00074 { 00075 i->second->unload(); 00076 delete i->second; 00077 } 00078 mResources.clear(); 00079 } 00080 }
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:22 2004