[657] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #include "OgreD3D9TextureManager.h"
|
---|
| 26 | #include "OgreD3D9Texture.h"
|
---|
| 27 | #include "OgreException.h"
|
---|
| 28 | #include "OgreLogManager.h"
|
---|
| 29 | #include "OgreStringConverter.h"
|
---|
| 30 |
|
---|
| 31 | namespace Ogre
|
---|
| 32 | {
|
---|
| 33 | D3D9TextureManager::D3D9TextureManager( LPDIRECT3DDEVICE9 pD3DDevice ) : TextureManager()
|
---|
| 34 | {
|
---|
| 35 | mpD3DDevice = pD3DDevice;
|
---|
| 36 | if( !mpD3DDevice )
|
---|
| 37 | OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "Invalid Direct3DDevice passed", "D3D9TextureManager::D3D9TextureManager" );
|
---|
| 38 | // register with group manager
|
---|
| 39 | ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | D3D9TextureManager::~D3D9TextureManager()
|
---|
| 43 | {
|
---|
| 44 | // unregister with group manager
|
---|
| 45 | ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
|
---|
| 46 |
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | Resource* D3D9TextureManager::createImpl(const String& name,
|
---|
| 50 | ResourceHandle handle, const String& group, bool isManual,
|
---|
| 51 | ManualResourceLoader* loader, const NameValuePairList* createParams)
|
---|
| 52 | {
|
---|
| 53 | return new D3D9Texture(this, name, handle, group, isManual, loader, mpD3DDevice);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | void D3D9TextureManager::releaseDefaultPoolResources(void)
|
---|
| 57 | {
|
---|
| 58 | size_t count = 0;
|
---|
| 59 |
|
---|
| 60 | ResourceMap::iterator r, rend;
|
---|
| 61 | rend = mResources.end();
|
---|
| 62 | for (r = mResources.begin(); r != rend; ++r)
|
---|
| 63 | {
|
---|
| 64 | D3D9TexturePtr t = r->second;
|
---|
| 65 | if (t->releaseIfDefaultPool())
|
---|
| 66 | count++;
|
---|
| 67 | }
|
---|
| 68 | LogManager::getSingleton().logMessage("D3D9TextureManager released:");
|
---|
| 69 | LogManager::getSingleton().logMessage(
|
---|
| 70 | StringConverter::toString(count) + " unmanaged textures");
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | void D3D9TextureManager::recreateDefaultPoolResources(void)
|
---|
| 74 | {
|
---|
| 75 | size_t count = 0;
|
---|
| 76 |
|
---|
| 77 | ResourceMap::iterator r, rend;
|
---|
| 78 | rend = mResources.end();
|
---|
| 79 | for (r = mResources.begin(); r != rend; ++r)
|
---|
| 80 | {
|
---|
| 81 | D3D9TexturePtr t = r->second;
|
---|
| 82 | if(t->recreateIfDefaultPool(mpD3DDevice))
|
---|
| 83 | count++;
|
---|
| 84 | }
|
---|
| 85 | LogManager::getSingleton().logMessage("D3D9TextureManager recreated:");
|
---|
| 86 | LogManager::getSingleton().logMessage(
|
---|
| 87 | StringConverter::toString(count) + " unmanaged textures");
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | }
|
---|