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-2014 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 29 /*************************************************************************** 30 OgreExternalTextureSourceManager.cpp - 31 Implementation of the manager class 32 33 ------------------- 34 date : Jan 1 2004 35 email : pjcast@yahoo.com 36 ***************************************************************************/ 37 38 #include "OgreStableHeaders.h" 39 #include "OgreExternalTextureSourceManager.h" 40 41 42 namespace Ogre 43 { 44 //**************************************************************************************** 45 template<> ExternalTextureSourceManager* Singleton<ExternalTextureSourceManager>::msSingleton = 0; getSingletonPtr(void)46 ExternalTextureSourceManager* ExternalTextureSourceManager::getSingletonPtr(void) 47 { 48 return msSingleton; 49 } getSingleton(void)50 ExternalTextureSourceManager& ExternalTextureSourceManager::getSingleton(void) 51 { 52 assert( msSingleton ); return ( *msSingleton ); 53 } 54 //**************************************************************************************** 55 56 //**************************************************************************************** ExternalTextureSourceManager()57 ExternalTextureSourceManager::ExternalTextureSourceManager() 58 { 59 mCurrExternalTextureSource = 0; 60 } 61 62 //**************************************************************************************** ~ExternalTextureSourceManager()63 ExternalTextureSourceManager::~ExternalTextureSourceManager() 64 { 65 mTextureSystems.clear(); 66 } 67 68 //**************************************************************************************** 69 setCurrentPlugIn(const String & sTexturePlugInType)70 void ExternalTextureSourceManager::setCurrentPlugIn( const String& sTexturePlugInType ) 71 { 72 TextureSystemList::iterator i; 73 74 for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) 75 { 76 if( i->first == sTexturePlugInType ) 77 { 78 mCurrExternalTextureSource = i->second; 79 mCurrExternalTextureSource->initialise(); //Now call overridden Init function 80 return; 81 } 82 } 83 mCurrExternalTextureSource = 0; 84 LogManager::getSingleton().logMessage( "ExternalTextureSourceManager::SetCurrentPlugIn(ENUM) failed setting texture plugin ", LML_CRITICAL); 85 } 86 87 //**************************************************************************************** destroyAdvancedTexture(const String & sTextureName,const String & groupName)88 void ExternalTextureSourceManager::destroyAdvancedTexture( const String& sTextureName, 89 const String& groupName ) 90 { 91 TextureSystemList::iterator i; 92 for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) 93 { 94 //Broadcast to every registered System... Only the true one will destroy texture 95 i->second->destroyAdvancedTexture( sTextureName, groupName ); 96 } 97 } 98 99 //**************************************************************************************** setExternalTextureSource(const String & sTexturePlugInType,ExternalTextureSource * pTextureSystem)100 void ExternalTextureSourceManager::setExternalTextureSource( const String& sTexturePlugInType, ExternalTextureSource* pTextureSystem ) 101 { 102 LogManager::getSingleton().logMessage( "Registering Texture Controller: Type = " 103 + sTexturePlugInType + " Name = " + pTextureSystem->getPluginStringName()); 104 105 TextureSystemList::iterator i; 106 107 for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) 108 { 109 if( i->first == sTexturePlugInType ) 110 { 111 LogManager::getSingleton().logMessage( "Shutting Down Texture Controller: " 112 + i->second->getPluginStringName() 113 + " To be replaced by: " 114 + pTextureSystem->getPluginStringName()); 115 116 i->second->shutDown(); //Only one plugIn of Sent Type can be registered at a time 117 //so shut down old plugin before starting new plugin 118 i->second = pTextureSystem; 119 // **Moved this line b/c Rendersystem needs to be selected before things 120 // such as framelistners can be added 121 // pTextureSystem->Initialise(); 122 return; 123 } 124 } 125 mTextureSystems[sTexturePlugInType] = pTextureSystem; //If we got here then add it to map 126 } 127 128 //**************************************************************************************** getExternalTextureSource(const String & sTexturePlugInType)129 ExternalTextureSource* ExternalTextureSourceManager::getExternalTextureSource( const String& sTexturePlugInType ) 130 { 131 TextureSystemList::iterator i; 132 for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) 133 { 134 if( i->first == sTexturePlugInType ) 135 return i->second; 136 } 137 return 0; 138 } 139 140 //**************************************************************************************** 141 142 } //End Ogre Namespace 143 144