source: OGRE/trunk/ogrenew/OgreMain/src/OgreExternalTextureSourceManager.cpp @ 657

Revision 657, 5.4 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

RevLine 
[657]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26/***************************************************************************
27OgreExternalTextureSourceManager.cpp  - 
28        Implementation of the manager class
29
30-------------------
31date                 : Jan 1 2004
32email                : pjcast@yahoo.com
33***************************************************************************/
34
35#include "OgreStableHeaders.h"
36#include "OgreExternalTextureSourceManager.h"
37#include "OgreLogManager.h"
38
39
40namespace Ogre
41{
42        //****************************************************************************************
43    template<> ExternalTextureSourceManager* Singleton<ExternalTextureSourceManager>::ms_Singleton = 0;
44    ExternalTextureSourceManager* ExternalTextureSourceManager::getSingletonPtr(void)
45    {
46        return ms_Singleton;
47    }
48    ExternalTextureSourceManager& ExternalTextureSourceManager::getSingleton(void)
49    { 
50        assert( ms_Singleton );  return ( *ms_Singleton ); 
51    }
52        //****************************************************************************************
53
54        //****************************************************************************************
55        ExternalTextureSourceManager::ExternalTextureSourceManager()
56        {
57                mpCurrExternalTextureSource = 0;
58        }
59
60        //****************************************************************************************
61        ExternalTextureSourceManager::~ExternalTextureSourceManager()
62        {
63                mTextureSystems.clear();
64        }
65
66        //****************************************************************************************
67       
68        void ExternalTextureSourceManager::setCurrentPlugIn( const String& sTexturePlugInType )
69        {
70                TextureSystemList::iterator i;
71                       
72                for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
73                {
74                        if( i->first == sTexturePlugInType )
75                        {
76                                mpCurrExternalTextureSource = i->second;
77                                mpCurrExternalTextureSource->initialise();      //Now call overridden Init function
78                                return;
79                        }
80                }
81                mpCurrExternalTextureSource = 0;
82                LogManager::getSingleton().logMessage( "ExternalTextureSourceManager::SetCurrentPlugIn(ENUM) failed setting texture plugin ");
83        }
84
85        //****************************************************************************************
86        void ExternalTextureSourceManager::destroyAdvancedTexture( const String& sTextureName,
87                const String& groupName )
88        {
89                TextureSystemList::iterator i;
90                for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
91                {
92                        //Broadcast to every registered System... Only the true one will destroy texture
93                        i->second->destroyAdvancedTexture( sTextureName, groupName );
94                }
95        }
96
97        //****************************************************************************************
98        void ExternalTextureSourceManager::setExternalTextureSource( const String& sTexturePlugInType, ExternalTextureSource* pTextureSystem )
99        {
100                LogManager::getSingleton().logMessage( "Registering Texture Controller: Type = "
101                                                + sTexturePlugInType + " Name = " + pTextureSystem->getPlugInStringName());
102
103                TextureSystemList::iterator i;
104                       
105                for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
106                {
107                        if( i->first == sTexturePlugInType )
108                        {
109                                LogManager::getSingleton().logMessage( "Shutting Down Texture Controller: "
110                                                + i->second->getPlugInStringName()
111                                                + " To be replaced by: "
112                                                + pTextureSystem->getPlugInStringName());
113
114                                i->second->shutDown();                          //Only one plugIn of Sent Type can be registered at a time
115                                                                                                        //so shut down old plugin before starting new plugin
116                                i->second = pTextureSystem;
117                                // **Moved this line b/c Rendersystem needs to be selected before things
118                                // such as framelistners can be added
119                                // pTextureSystem->Initialise();
120                                return;
121                        }
122                }
123                mTextureSystems[sTexturePlugInType] = pTextureSystem;   //If we got here then add it to map
124        }
125
126        //****************************************************************************************
127        ExternalTextureSource* ExternalTextureSourceManager::getExternalTextureSource( const String& sTexturePlugInType )
128        {
129                TextureSystemList::iterator i;
130                for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
131                {
132                        if( i->first == sTexturePlugInType )
133                                return i->second;
134                }
135                return 0;
136        }
137
138        //****************************************************************************************
139
140}  //End Ogre Namespace
141
Note: See TracBrowser for help on using the repository browser.