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/
7 Copyright (c) 2000-2006 Torus Knot Software Ltd
8 Also see acknowledgements in Readme.html
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
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.
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.
24 You may alternatively use this source under the terms of a specific version of
25 the OGRE Unrestricted License provided you have obtained such a license from
26 Torus Knot Software Ltd.
27 -----------------------------------------------------------------------------
30 /***************************************************************************
31 OgreExternalTextureSourceManager.cpp -
32 Implementation of the manager class
36 email : pjcast@yahoo.com
37 ***************************************************************************/
39 #include "OgreStableHeaders.h"
40 #include "OgreExternalTextureSourceManager.h"
41 #include "OgreLogManager.h"
46 //****************************************************************************************
47 template<> ExternalTextureSourceManager
* Singleton
<ExternalTextureSourceManager
>::ms_Singleton
= 0;
48 ExternalTextureSourceManager
* ExternalTextureSourceManager::getSingletonPtr(void)
52 ExternalTextureSourceManager
& ExternalTextureSourceManager::getSingleton(void)
54 assert( ms_Singleton
); return ( *ms_Singleton
);
56 //****************************************************************************************
58 //****************************************************************************************
59 ExternalTextureSourceManager::ExternalTextureSourceManager()
61 mpCurrExternalTextureSource
= 0;
64 //****************************************************************************************
65 ExternalTextureSourceManager::~ExternalTextureSourceManager()
67 mTextureSystems
.clear();
70 //****************************************************************************************
72 void ExternalTextureSourceManager::setCurrentPlugIn( const String
& sTexturePlugInType
)
74 TextureSystemList::iterator i
;
76 for( i
= mTextureSystems
.begin(); i
!= mTextureSystems
.end(); ++i
)
78 if( i
->first
== sTexturePlugInType
)
80 mpCurrExternalTextureSource
= i
->second
;
81 mpCurrExternalTextureSource
->initialise(); //Now call overridden Init function
85 mpCurrExternalTextureSource
= 0;
86 LogManager::getSingleton().logMessage( "ExternalTextureSourceManager::SetCurrentPlugIn(ENUM) failed setting texture plugin ");
89 //****************************************************************************************
90 void ExternalTextureSourceManager::destroyAdvancedTexture( const String
& sTextureName
,
91 const String
& groupName
)
93 TextureSystemList::iterator i
;
94 for( i
= mTextureSystems
.begin(); i
!= mTextureSystems
.end(); ++i
)
96 //Broadcast to every registered System... Only the true one will destroy texture
97 i
->second
->destroyAdvancedTexture( sTextureName
, groupName
);
101 //****************************************************************************************
102 void ExternalTextureSourceManager::setExternalTextureSource( const String
& sTexturePlugInType
, ExternalTextureSource
* pTextureSystem
)
104 LogManager::getSingleton().logMessage( "Registering Texture Controller: Type = "
105 + sTexturePlugInType
+ " Name = " + pTextureSystem
->getPlugInStringName());
107 TextureSystemList::iterator i
;
109 for( i
= mTextureSystems
.begin(); i
!= mTextureSystems
.end(); ++i
)
111 if( i
->first
== sTexturePlugInType
)
113 LogManager::getSingleton().logMessage( "Shutting Down Texture Controller: "
114 + i
->second
->getPlugInStringName()
115 + " To be replaced by: "
116 + pTextureSystem
->getPlugInStringName());
118 i
->second
->shutDown(); //Only one plugIn of Sent Type can be registered at a time
119 //so shut down old plugin before starting new plugin
120 i
->second
= pTextureSystem
;
121 // **Moved this line b/c Rendersystem needs to be selected before things
122 // such as framelistners can be added
123 // pTextureSystem->Initialise();
127 mTextureSystems
[sTexturePlugInType
] = pTextureSystem
; //If we got here then add it to map
130 //****************************************************************************************
131 ExternalTextureSource
* ExternalTextureSourceManager::getExternalTextureSource( const String
& sTexturePlugInType
)
133 TextureSystemList::iterator i
;
134 for( i
= mTextureSystems
.begin(); i
!= mTextureSystems
.end(); ++i
)
136 if( i
->first
== sTexturePlugInType
)
142 //****************************************************************************************
144 } //End Ogre Namespace