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-2006 Torus Knot Software Ltd |
---|
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 | 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 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | |
---|
30 | /*************************************************************************** |
---|
31 | OgreExternalTextureSourceManager.cpp - |
---|
32 | Implementation of the manager class |
---|
33 | |
---|
34 | ------------------- |
---|
35 | date : Jan 1 2004 |
---|
36 | email : pjcast@yahoo.com |
---|
37 | ***************************************************************************/ |
---|
38 | |
---|
39 | #include "OgreStableHeaders.h" |
---|
40 | #include "OgreExternalTextureSourceManager.h" |
---|
41 | #include "OgreLogManager.h" |
---|
42 | |
---|
43 | |
---|
44 | namespace Ogre |
---|
45 | { |
---|
46 | //**************************************************************************************** |
---|
47 | template<> ExternalTextureSourceManager* Singleton<ExternalTextureSourceManager>::ms_Singleton = 0; |
---|
48 | ExternalTextureSourceManager* ExternalTextureSourceManager::getSingletonPtr(void) |
---|
49 | { |
---|
50 | return ms_Singleton; |
---|
51 | } |
---|
52 | ExternalTextureSourceManager& ExternalTextureSourceManager::getSingleton(void) |
---|
53 | { |
---|
54 | assert( ms_Singleton ); return ( *ms_Singleton ); |
---|
55 | } |
---|
56 | //**************************************************************************************** |
---|
57 | |
---|
58 | //**************************************************************************************** |
---|
59 | ExternalTextureSourceManager::ExternalTextureSourceManager() |
---|
60 | { |
---|
61 | mpCurrExternalTextureSource = 0; |
---|
62 | } |
---|
63 | |
---|
64 | //**************************************************************************************** |
---|
65 | ExternalTextureSourceManager::~ExternalTextureSourceManager() |
---|
66 | { |
---|
67 | mTextureSystems.clear(); |
---|
68 | } |
---|
69 | |
---|
70 | //**************************************************************************************** |
---|
71 | |
---|
72 | void ExternalTextureSourceManager::setCurrentPlugIn( const String& sTexturePlugInType ) |
---|
73 | { |
---|
74 | TextureSystemList::iterator i; |
---|
75 | |
---|
76 | for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) |
---|
77 | { |
---|
78 | if( i->first == sTexturePlugInType ) |
---|
79 | { |
---|
80 | mpCurrExternalTextureSource = i->second; |
---|
81 | mpCurrExternalTextureSource->initialise(); //Now call overridden Init function |
---|
82 | return; |
---|
83 | } |
---|
84 | } |
---|
85 | mpCurrExternalTextureSource = 0; |
---|
86 | LogManager::getSingleton().logMessage( "ExternalTextureSourceManager::SetCurrentPlugIn(ENUM) failed setting texture plugin "); |
---|
87 | } |
---|
88 | |
---|
89 | //**************************************************************************************** |
---|
90 | void ExternalTextureSourceManager::destroyAdvancedTexture( const String& sTextureName, |
---|
91 | const String& groupName ) |
---|
92 | { |
---|
93 | TextureSystemList::iterator i; |
---|
94 | for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) |
---|
95 | { |
---|
96 | //Broadcast to every registered System... Only the true one will destroy texture |
---|
97 | i->second->destroyAdvancedTexture( sTextureName, groupName ); |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | //**************************************************************************************** |
---|
102 | void ExternalTextureSourceManager::setExternalTextureSource( const String& sTexturePlugInType, ExternalTextureSource* pTextureSystem ) |
---|
103 | { |
---|
104 | LogManager::getSingleton().logMessage( "Registering Texture Controller: Type = " |
---|
105 | + sTexturePlugInType + " Name = " + pTextureSystem->getPlugInStringName()); |
---|
106 | |
---|
107 | TextureSystemList::iterator i; |
---|
108 | |
---|
109 | for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) |
---|
110 | { |
---|
111 | if( i->first == sTexturePlugInType ) |
---|
112 | { |
---|
113 | LogManager::getSingleton().logMessage( "Shutting Down Texture Controller: " |
---|
114 | + i->second->getPlugInStringName() |
---|
115 | + " To be replaced by: " |
---|
116 | + pTextureSystem->getPlugInStringName()); |
---|
117 | |
---|
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(); |
---|
124 | return; |
---|
125 | } |
---|
126 | } |
---|
127 | mTextureSystems[sTexturePlugInType] = pTextureSystem; //If we got here then add it to map |
---|
128 | } |
---|
129 | |
---|
130 | //**************************************************************************************** |
---|
131 | ExternalTextureSource* ExternalTextureSourceManager::getExternalTextureSource( const String& sTexturePlugInType ) |
---|
132 | { |
---|
133 | TextureSystemList::iterator i; |
---|
134 | for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) |
---|
135 | { |
---|
136 | if( i->first == sTexturePlugInType ) |
---|
137 | return i->second; |
---|
138 | } |
---|
139 | return 0; |
---|
140 | } |
---|
141 | |
---|
142 | //**************************************************************************************** |
---|
143 | |
---|
144 | } //End Ogre Namespace |
---|
145 | |
---|