Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreExternalTextureSourceManager.cpp

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright © 2000-2004 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025
    00026 /***************************************************************************
    00027 OgreExternalTextureSourceManager.cpp  -
    00028     Implementation of the manager class
    00029
    00030 -------------------
    00031 date                 : Jan 1 2004
    00032 email                : pjcast@yahoo.com
    00033 ***************************************************************************/
    00034
    00035 #include "OgreStableHeaders.h"
    00036 #include "OgreExternalTextureSourceManager.h"
    00037 #include "OgreLogManager.h"
    00038
    00039
    00040 namespace Ogre
    00041 {
    00042     //****************************************************************************************
    00043     template<> ExternalTextureSourceManager* Singleton<ExternalTextureSourceManager>::ms_Singleton = 0;
    00044     ExternalTextureSourceManager* ExternalTextureSourceManager::getSingletonPtr(void)
    00045     {
    00046         return ms_Singleton;
    00047     }
    00048     ExternalTextureSourceManager& ExternalTextureSourceManager::getSingleton(void)
    00049     {
    00050         assert( ms_Singleton );  return ( *ms_Singleton );
    00051     }
    00052     //****************************************************************************************
    00053
    00054     //****************************************************************************************
    00055     ExternalTextureSourceManager::ExternalTextureSourceManager()
    00056     {
    00057         mpCurrExternalTextureSource = 0;
    00058     }
    00059
    00060     //****************************************************************************************
    00061     ExternalTextureSourceManager::~ExternalTextureSourceManager()
    00062     {
    00063         mTextureSystems.clear();
    00064     }
    00065
    00066     //****************************************************************************************
    00067
    00068     void ExternalTextureSourceManager::SetCurrentPlugIn( const String& sTexturePlugInType )
    00069     {
    00070         TextureSystemList::iterator i;
    00071
    00072         for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
    00073         {
    00074             if( i->first == sTexturePlugInType )
    00075             {
    00076                 mpCurrExternalTextureSource = i->second;
    00077                 mpCurrExternalTextureSource->Initialise();  //Now call overridden Init function
    00078                 return;
    00079             }
    00080         }
    00081         mpCurrExternalTextureSource = 0;
    00082         LogManager::getSingleton().logMessage( "ExternalTextureSourceManager::SetCurrentPlugIn(ENUM) failed setting texture plugin ");
    00083     }
    00084
    00085     //****************************************************************************************
    00086     void ExternalTextureSourceManager::DestroyAdvancedTexture( const String& sTextureName )
    00087     {
    00088         TextureSystemList::iterator i;
    00089         for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
    00090         {
    00091             //Broadcast to every registered System... Only the true one will destroy texture
    00092             i->second->DestroyAdvancedTexture( sTextureName );
    00093         }
    00094     }
    00095
    00096     //****************************************************************************************
    00097     void ExternalTextureSourceManager::setExternalTextureSource( const String& sTexturePlugInType, ExternalTextureSource* pTextureSystem )
    00098     {
    00099         LogManager::getSingleton().logMessage( "Registering Texture Controller: Type = "
    00100                         + sTexturePlugInType + " Name = " + pTextureSystem->getPlugInStringName());
    00101
    00102         TextureSystemList::iterator i;
    00103
    00104         for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
    00105         {
    00106             if( i->first == sTexturePlugInType )
    00107             {
    00108                 LogManager::getSingleton().logMessage( "Shutting Down Texture Controller: "
    00109                         + i->second->getPlugInStringName()
    00110                         + " To be replaced by: "
    00111                         + pTextureSystem->getPlugInStringName());
    00112
    00113                 i->second->ShutDown();              //Only one plugIn of Sent Type can be registered at a time
    00114                                                     //so shut down old plugin before starting new plugin
    00115                 i->second = pTextureSystem;
    00116                 // **Moved this line b/c Rendersystem needs to be selected before things
    00117                 // such as framelistners can be added
    00118                 // pTextureSystem->Initialise();
    00119                 return;
    00120             }
    00121         }
    00122         mTextureSystems[sTexturePlugInType] = pTextureSystem;   //If we got here then add it to map
    00123     }
    00124
    00125     //****************************************************************************************
    00126     ExternalTextureSource* ExternalTextureSourceManager::getExternalTextureSource( const String& sTexturePlugInType )
    00127     {
    00128         TextureSystemList::iterator i;
    00129         for( i = mTextureSystems.begin(); i != mTextureSystems.end(); ++i )
    00130         {
    00131             if( i->first == sTexturePlugInType )
    00132                 return i->second;
    00133         }
    00134         return 0;
    00135     }
    00136
    00137     //****************************************************************************************
    00138
    00139 }  //End Ogre Namespace
    00140

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:24 2004