| 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 | #ifndef _OgreExternalTextureSourceManager_H |
|---|
| 30 | #define _OgreExternalTextureSourceManager_H |
|---|
| 31 | |
|---|
| 32 | /*************************************************************************** |
|---|
| 33 | OgreExternalTextureSourceManager.h - |
|---|
| 34 | Handles the registering / unregistering of texture modifier plugins |
|---|
| 35 | |
|---|
| 36 | ------------------- |
|---|
| 37 | date : Jan 1 2004 |
|---|
| 38 | email : pjcast@yahoo.com |
|---|
| 39 | ***************************************************************************/ |
|---|
| 40 | #include "OgreSingleton.h" |
|---|
| 41 | #include "OgreString.h" |
|---|
| 42 | #include "OgreResourceGroupManager.h" |
|---|
| 43 | #include "OgreExternalTextureSource.h" |
|---|
| 44 | |
|---|
| 45 | namespace Ogre |
|---|
| 46 | { |
|---|
| 47 | /** |
|---|
| 48 | Singleton Class which handles the registering and control of texture plugins. The plugins |
|---|
| 49 | will be mostly controlled via a string interface. */ |
|---|
| 50 | class _OgreExport ExternalTextureSourceManager : public Singleton<ExternalTextureSourceManager> |
|---|
| 51 | { |
|---|
| 52 | public: |
|---|
| 53 | /** Constructor */ |
|---|
| 54 | ExternalTextureSourceManager(); |
|---|
| 55 | /** Destructor */ |
|---|
| 56 | ~ExternalTextureSourceManager(); |
|---|
| 57 | |
|---|
| 58 | /** Sets active plugin (ie. "video", "effect", "generic", etc..) */ |
|---|
| 59 | void setCurrentPlugIn( const String& sTexturePlugInType ); |
|---|
| 60 | |
|---|
| 61 | /** Returns currently selected plugin, may be null if none selected */ |
|---|
| 62 | ExternalTextureSource* getCurrentPlugIn( void ) const { return mpCurrExternalTextureSource; } |
|---|
| 63 | |
|---|
| 64 | /** Calls the destroy method of all registered plugins... |
|---|
| 65 | Only the owner plugin should perform the destroy action. */ |
|---|
| 66 | void destroyAdvancedTexture( const String& sTextureName, |
|---|
| 67 | const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); |
|---|
| 68 | |
|---|
| 69 | /** Returns the plugin which reistered itself with a specific name |
|---|
| 70 | (eg. "video"), or null if specified plugin not found */ |
|---|
| 71 | ExternalTextureSource* getExternalTextureSource( const String& sTexturePlugInType ); |
|---|
| 72 | |
|---|
| 73 | /** Called from plugin to register itself */ |
|---|
| 74 | void setExternalTextureSource( const String& sTexturePlugInType, ExternalTextureSource* pTextureSystem ); |
|---|
| 75 | |
|---|
| 76 | /** Override standard Singleton retrieval. |
|---|
| 77 | @remarks |
|---|
| 78 | Why do we do this? Well, it's because the Singleton |
|---|
| 79 | implementation is in a .h file, which means it gets compiled |
|---|
| 80 | into anybody who includes it. This is needed for the |
|---|
| 81 | Singleton template to work, but we actually only want it |
|---|
| 82 | compiled into the implementation of the class based on the |
|---|
| 83 | Singleton, not all of them. If we don't change this, we get |
|---|
| 84 | link errors when trying to use the Singleton-based class from |
|---|
| 85 | an outside dll. |
|---|
| 86 | @par |
|---|
| 87 | This method just delegates to the template version anyway, |
|---|
| 88 | but the implementation stays in this single compilation unit, |
|---|
| 89 | preventing link errors. |
|---|
| 90 | */ |
|---|
| 91 | static ExternalTextureSourceManager& getSingleton(void); |
|---|
| 92 | /** Override standard Singleton retrieval. |
|---|
| 93 | @remarks |
|---|
| 94 | Why do we do this? Well, it's because the Singleton |
|---|
| 95 | implementation is in a .h file, which means it gets compiled |
|---|
| 96 | into anybody who includes it. This is needed for the |
|---|
| 97 | Singleton template to work, but we actually only want it |
|---|
| 98 | compiled into the implementation of the class based on the |
|---|
| 99 | Singleton, not all of them. If we don't change this, we get |
|---|
| 100 | link errors when trying to use the Singleton-based class from |
|---|
| 101 | an outside dll. |
|---|
| 102 | @par |
|---|
| 103 | This method just delegates to the template version anyway, |
|---|
| 104 | but the implementation stays in this single compilation unit, |
|---|
| 105 | preventing link errors. |
|---|
| 106 | */ |
|---|
| 107 | static ExternalTextureSourceManager* getSingletonPtr(void); |
|---|
| 108 | protected: |
|---|
| 109 | //The current texture controller selected |
|---|
| 110 | ExternalTextureSource* mpCurrExternalTextureSource; |
|---|
| 111 | |
|---|
| 112 | // Collection of loaded texture System PlugIns, keyed by registered type |
|---|
| 113 | typedef std::map< String, ExternalTextureSource*> TextureSystemList; |
|---|
| 114 | TextureSystemList mTextureSystems; |
|---|
| 115 | }; |
|---|
| 116 | } |
|---|
| 117 | #endif |
|---|