| 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 __CompositionTechnique_H__ |
|---|
| 30 | #define __CompositionTechnique_H__ |
|---|
| 31 | |
|---|
| 32 | #include "OgrePrerequisites.h" |
|---|
| 33 | #include "OgrePixelFormat.h" |
|---|
| 34 | #include "OgreIteratorWrappers.h" |
|---|
| 35 | |
|---|
| 36 | namespace Ogre { |
|---|
| 37 | /** Base composition technique, can be subclassed in plugins. |
|---|
| 38 | */ |
|---|
| 39 | class _OgreExport CompositionTechnique |
|---|
| 40 | { |
|---|
| 41 | public: |
|---|
| 42 | CompositionTechnique(Compositor *parent); |
|---|
| 43 | virtual ~CompositionTechnique(); |
|---|
| 44 | |
|---|
| 45 | /// Local texture definition |
|---|
| 46 | class TextureDefinition |
|---|
| 47 | { |
|---|
| 48 | public: |
|---|
| 49 | String name; |
|---|
| 50 | size_t width; // 0 means adapt to target width |
|---|
| 51 | size_t height; // 0 means adapt to target height |
|---|
| 52 | PixelFormat format; |
|---|
| 53 | |
|---|
| 54 | TextureDefinition() :width(0), height(0), format(PF_R8G8B8A8){} |
|---|
| 55 | }; |
|---|
| 56 | /// Typedefs for several iterators |
|---|
| 57 | typedef std::vector<CompositionTargetPass *> TargetPasses; |
|---|
| 58 | typedef VectorIterator<TargetPasses> TargetPassIterator; |
|---|
| 59 | typedef std::vector<TextureDefinition*> TextureDefinitions; |
|---|
| 60 | typedef VectorIterator<TextureDefinitions> TextureDefinitionIterator; |
|---|
| 61 | |
|---|
| 62 | /** Create a new local texture definition, and return a pointer to it. |
|---|
| 63 | @param name Name of the local texture |
|---|
| 64 | */ |
|---|
| 65 | TextureDefinition *createTextureDefinition(const String &name); |
|---|
| 66 | |
|---|
| 67 | /** Remove and destroy a local texture definition. |
|---|
| 68 | */ |
|---|
| 69 | void removeTextureDefinition(size_t idx); |
|---|
| 70 | |
|---|
| 71 | /** Get a local texture definition. |
|---|
| 72 | */ |
|---|
| 73 | TextureDefinition *getTextureDefinition(size_t idx); |
|---|
| 74 | |
|---|
| 75 | /** Get the number of local texture definitions. |
|---|
| 76 | */ |
|---|
| 77 | size_t getNumTextureDefinitions(); |
|---|
| 78 | |
|---|
| 79 | /** Remove all Texture Definitions |
|---|
| 80 | */ |
|---|
| 81 | void removeAllTextureDefinitions(); |
|---|
| 82 | |
|---|
| 83 | /** Get an iterator over the TextureDefinitions in this Technique. */ |
|---|
| 84 | TextureDefinitionIterator getTextureDefinitionIterator(void); |
|---|
| 85 | |
|---|
| 86 | /** Create a new target pass, and return a pointer to it. |
|---|
| 87 | */ |
|---|
| 88 | CompositionTargetPass *createTargetPass(); |
|---|
| 89 | |
|---|
| 90 | /** Remove a target pass. It will also be destroyed. |
|---|
| 91 | */ |
|---|
| 92 | void removeTargetPass(size_t idx); |
|---|
| 93 | |
|---|
| 94 | /** Get a target pass. |
|---|
| 95 | */ |
|---|
| 96 | CompositionTargetPass *getTargetPass(size_t idx); |
|---|
| 97 | |
|---|
| 98 | /** Get the number of target passes. |
|---|
| 99 | */ |
|---|
| 100 | size_t getNumTargetPasses(); |
|---|
| 101 | |
|---|
| 102 | /** Remove all target passes. |
|---|
| 103 | */ |
|---|
| 104 | void removeAllTargetPasses(); |
|---|
| 105 | |
|---|
| 106 | /** Get an iterator over the TargetPasses in this Technique. */ |
|---|
| 107 | TargetPassIterator getTargetPassIterator(void); |
|---|
| 108 | |
|---|
| 109 | /** Get output (final) target pass |
|---|
| 110 | */ |
|---|
| 111 | CompositionTargetPass *getOutputTargetPass(); |
|---|
| 112 | |
|---|
| 113 | /** Determine if this technique is supported on the current rendering device. |
|---|
| 114 | @param allowTextureDegradation True to accept a reduction in texture depth |
|---|
| 115 | */ |
|---|
| 116 | virtual bool isSupported(bool allowTextureDegradation); |
|---|
| 117 | |
|---|
| 118 | /** Create an instance of this technique. |
|---|
| 119 | */ |
|---|
| 120 | virtual CompositorInstance *createInstance(CompositorChain *chain); |
|---|
| 121 | |
|---|
| 122 | /** Destroy an instance of this technique. |
|---|
| 123 | */ |
|---|
| 124 | virtual void destroyInstance(CompositorInstance *instance); |
|---|
| 125 | |
|---|
| 126 | /** Get parent object */ |
|---|
| 127 | Compositor *getParent(); |
|---|
| 128 | private: |
|---|
| 129 | /// Parent compositor |
|---|
| 130 | Compositor *mParent; |
|---|
| 131 | /// Local texture definitions |
|---|
| 132 | TextureDefinitions mTextureDefinitions; |
|---|
| 133 | |
|---|
| 134 | /// Intermediate target passes |
|---|
| 135 | TargetPasses mTargetPasses; |
|---|
| 136 | /// Output target pass (can be only one) |
|---|
| 137 | CompositionTargetPass *mOutputTarget; |
|---|
| 138 | |
|---|
| 139 | /// List of instances |
|---|
| 140 | typedef std::vector<CompositorInstance *> Instances; |
|---|
| 141 | Instances mInstances; |
|---|
| 142 | }; |
|---|
| 143 | |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | #endif |
|---|