/src/ogre/OgreMain/src/OgreExternalTextureSourceManager.cpp
Line | Count | Source |
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; |
46 | | ExternalTextureSourceManager* ExternalTextureSourceManager::getSingletonPtr(void) |
47 | 0 | { |
48 | 0 | return msSingleton; |
49 | 0 | } |
50 | | ExternalTextureSourceManager& ExternalTextureSourceManager::getSingleton(void) |
51 | 0 | { |
52 | 0 | assert( msSingleton ); return ( *msSingleton ); |
53 | 0 | } |
54 | | //**************************************************************************************** |
55 | | |
56 | | //**************************************************************************************** |
57 | | ExternalTextureSourceManager::ExternalTextureSourceManager() |
58 | 1 | { |
59 | 1 | mCurrExternalTextureSource = 0; |
60 | 1 | } |
61 | | |
62 | | //**************************************************************************************** |
63 | | ExternalTextureSourceManager::~ExternalTextureSourceManager() |
64 | 1 | { |
65 | 1 | mTextureSystems.clear(); |
66 | 1 | } |
67 | | |
68 | | //**************************************************************************************** |
69 | | |
70 | | void ExternalTextureSourceManager::setCurrentPlugIn( const String& sTexturePlugInType ) |
71 | 0 | { |
72 | 0 | TextureSystemList::iterator i; |
73 | | |
74 | 0 | for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i ) |
75 | 0 | { |
76 | 0 | if( i->first == sTexturePlugInType ) |
77 | 0 | { |
78 | 0 | mCurrExternalTextureSource = i->second; |
79 | 0 | mCurrExternalTextureSource->initialise(); //Now call overridden Init function |
80 | 0 | return; |
81 | 0 | } |
82 | 0 | } |
83 | 0 | mCurrExternalTextureSource = 0; |
84 | 0 | } |
85 | | |
86 | | //**************************************************************************************** |
87 | | void ExternalTextureSourceManager::destroyAdvancedTexture( const String& sTextureName, |
88 | | const String& groupName ) |
89 | 0 | { |
90 | 0 | for(auto& t : mTextureSystems) |
91 | 0 | { |
92 | | //Broadcast to every registered System... Only the true one will destroy texture |
93 | 0 | t.second->destroyAdvancedTexture( sTextureName, groupName ); |
94 | 0 | } |
95 | 0 | } |
96 | | |
97 | | //**************************************************************************************** |
98 | | void ExternalTextureSourceManager::setExternalTextureSource( const String& sTexturePlugInType, ExternalTextureSource* pTextureSystem ) |
99 | 0 | { |
100 | 0 | LogManager::getSingleton().logMessage( "Registering Texture Controller: Type = " |
101 | 0 | + sTexturePlugInType + " Name = " + pTextureSystem->getPluginStringName()); |
102 | |
|
103 | 0 | for(auto& t : mTextureSystems) |
104 | 0 | { |
105 | 0 | if( t.first == sTexturePlugInType ) |
106 | 0 | { |
107 | 0 | LogManager::getSingleton().logMessage( "Shutting Down Texture Controller: " |
108 | 0 | + t.second->getPluginStringName() |
109 | 0 | + " To be replaced by: " |
110 | 0 | + pTextureSystem->getPluginStringName()); |
111 | |
|
112 | 0 | t.second->shutDown(); //Only one plugIn of Sent Type can be registered at a time |
113 | | //so shut down old plugin before starting new plugin |
114 | 0 | t.second = pTextureSystem; |
115 | | // **Moved this line b/c Rendersystem needs to be selected before things |
116 | | // such as framelistners can be added |
117 | | // pTextureSystem->Initialise(); |
118 | 0 | return; |
119 | 0 | } |
120 | 0 | } |
121 | 0 | mTextureSystems[sTexturePlugInType] = pTextureSystem; //If we got here then add it to map |
122 | 0 | } |
123 | | |
124 | | //**************************************************************************************** |
125 | | ExternalTextureSource* ExternalTextureSourceManager::getExternalTextureSource( const String& sTexturePlugInType ) |
126 | 0 | { |
127 | 0 | for(auto& t : mTextureSystems) |
128 | 0 | { |
129 | 0 | if(t.first == sTexturePlugInType) |
130 | 0 | return t.second; |
131 | 0 | } |
132 | 0 | return 0; |
133 | 0 | } |
134 | | |
135 | | //**************************************************************************************** |
136 | | |
137 | | } //End Ogre Namespace |
138 | | |