| [148] | 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-2013 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 | #ifndef __Compositor_H__ | 
|---|
 | 29 | #define __Compositor_H__ | 
|---|
 | 30 |  | 
|---|
 | 31 | #include "OgrePrerequisites.h" | 
|---|
 | 32 | #include "OgreIteratorWrappers.h" | 
|---|
 | 33 | #include "OgreResource.h" | 
|---|
 | 34 | #include "OgreTexture.h" | 
|---|
 | 35 | #include "OgreHeaderPrefix.h" | 
|---|
 | 36 |  | 
|---|
 | 37 | namespace Ogre { | 
|---|
 | 38 |         /** \addtogroup Core | 
|---|
 | 39 |         *  @{ | 
|---|
 | 40 |         */ | 
|---|
 | 41 |         /** \addtogroup Effects | 
|---|
 | 42 |         *  @{ | 
|---|
 | 43 |         */ | 
|---|
 | 44 |         /** Class representing a Compositor object. Compositors provide the means  | 
|---|
 | 45 |         to flexibly "composite" the final rendering result from multiple scene renders | 
|---|
 | 46 |         and intermediate operations like rendering fullscreen quads. This makes  | 
|---|
 | 47 |         it possible to apply postfilter effects, HDRI postprocessing, and shadow  | 
|---|
 | 48 |         effects to a Viewport. | 
|---|
 | 49 |      */ | 
|---|
 | 50 |     class _OgreExport Compositor: public Resource | 
|---|
 | 51 |     { | 
|---|
 | 52 |     public: | 
|---|
 | 53 |         Compositor(ResourceManager* creator, const String& name, ResourceHandle handle, | 
|---|
 | 54 |             const String& group, bool isManual = false, ManualResourceLoader* loader = 0); | 
|---|
 | 55 |         ~Compositor(); | 
|---|
 | 56 |          | 
|---|
 | 57 |         /// Data types for internal lists | 
|---|
 | 58 |         typedef vector<CompositionTechnique *>::type Techniques; | 
|---|
 | 59 |         typedef VectorIterator<Techniques> TechniqueIterator; | 
|---|
 | 60 |          | 
|---|
 | 61 |         /** Create a new technique, and return a pointer to it. | 
|---|
 | 62 |         */ | 
|---|
 | 63 |         CompositionTechnique *createTechnique(); | 
|---|
 | 64 |          | 
|---|
 | 65 |         /** Remove a technique. It will also be destroyed. | 
|---|
 | 66 |         */ | 
|---|
 | 67 |         void removeTechnique(size_t idx); | 
|---|
 | 68 |          | 
|---|
 | 69 |         /** Get a technique. | 
|---|
 | 70 |         */ | 
|---|
 | 71 |         CompositionTechnique *getTechnique(size_t idx); | 
|---|
 | 72 |          | 
|---|
 | 73 |         /** Get the number of techniques. | 
|---|
 | 74 |         */ | 
|---|
 | 75 |         size_t getNumTechniques(); | 
|---|
 | 76 |          | 
|---|
 | 77 |         /** Remove all techniques | 
|---|
 | 78 |         */ | 
|---|
 | 79 |         void removeAllTechniques(); | 
|---|
 | 80 |          | 
|---|
 | 81 |         /** Get an iterator over the Techniques in this compositor. */ | 
|---|
 | 82 |         TechniqueIterator getTechniqueIterator(void); | 
|---|
 | 83 |          | 
|---|
 | 84 |         /** Get a supported technique. | 
|---|
 | 85 |         @remarks | 
|---|
 | 86 |             The supported technique list is only available after this compositor has been compiled, | 
|---|
 | 87 |             which typically happens on loading it. Therefore, if this method returns | 
|---|
 | 88 |             an empty list, try calling Compositor::load. | 
|---|
 | 89 |         */ | 
|---|
 | 90 |         CompositionTechnique *getSupportedTechnique(size_t idx); | 
|---|
 | 91 |          | 
|---|
 | 92 |         /** Get the number of supported techniques. | 
|---|
 | 93 |         @remarks | 
|---|
 | 94 |             The supported technique list is only available after this compositor has been compiled, | 
|---|
 | 95 |             which typically happens on loading it. Therefore, if this method returns | 
|---|
 | 96 |             an empty list, try calling Compositor::load. | 
|---|
 | 97 |         */ | 
|---|
 | 98 |         size_t getNumSupportedTechniques(); | 
|---|
 | 99 |          | 
|---|
 | 100 |         /** Gets an iterator over all the Techniques which are supported by the current card.  | 
|---|
 | 101 |         @remarks | 
|---|
 | 102 |             The supported technique list is only available after this compositor has been compiled, | 
|---|
 | 103 |             which typically happens on loading it. Therefore, if this method returns | 
|---|
 | 104 |             an empty list, try calling Compositor::load. | 
|---|
 | 105 |         */ | 
|---|
 | 106 |         TechniqueIterator getSupportedTechniqueIterator(void); | 
|---|
 | 107 |  | 
|---|
 | 108 |                 /** Get a pointer to a supported technique for a given scheme.  | 
|---|
 | 109 |                 @remarks | 
|---|
 | 110 |                         If there is no specific supported technique with this scheme name,  | 
|---|
 | 111 |                         then the first supported technique with no specific scheme will be returned. | 
|---|
 | 112 |                 @param schemeName The scheme name you are looking for. Blank means to  | 
|---|
 | 113 |                         look for techniques with no scheme associated | 
|---|
 | 114 |                 */ | 
|---|
 | 115 |                 CompositionTechnique *getSupportedTechnique(const String& schemeName = StringUtil::BLANK); | 
|---|
 | 116 |  | 
|---|
 | 117 |                 /** Get the instance name for a global texture. | 
|---|
 | 118 |                 @param name The name of the texture in the original compositor definition | 
|---|
 | 119 |                 @param mrtIndex If name identifies a MRT, which texture attachment to retrieve | 
|---|
 | 120 |                 @return The instance name for the texture, corresponds to a real texture | 
|---|
 | 121 |                 */ | 
|---|
 | 122 |                 const String& getTextureInstanceName(const String& name, size_t mrtIndex); | 
|---|
 | 123 |  | 
|---|
 | 124 |                 /** Get the instance of a global texture. | 
|---|
 | 125 |                 @param name The name of the texture in the original compositor definition | 
|---|
 | 126 |                 @param mrtIndex If name identifies a MRT, which texture attachment to retrieve | 
|---|
 | 127 |                 @return The texture pointer, corresponds to a real texture | 
|---|
 | 128 |                 */ | 
|---|
 | 129 |                 TexturePtr getTextureInstance(const String& name, size_t mrtIndex); | 
|---|
 | 130 |  | 
|---|
 | 131 |                 /** Get the render target for a given render texture name.  | 
|---|
 | 132 |                 @remarks | 
|---|
 | 133 |                         You can use this to add listeners etc, but do not use it to update the | 
|---|
 | 134 |                         targets manually or any other modifications, the compositor instance  | 
|---|
 | 135 |                         is in charge of this. | 
|---|
 | 136 |                 */ | 
|---|
 | 137 |                 RenderTarget* getRenderTarget(const String& name); | 
|---|
 | 138 |  | 
|---|
 | 139 |     protected: | 
|---|
 | 140 |         /// @copydoc Resource::loadImpl | 
|---|
 | 141 |         void loadImpl(void); | 
|---|
 | 142 |  | 
|---|
 | 143 |         /// @copydoc Resource::unloadImpl | 
|---|
 | 144 |         void unloadImpl(void); | 
|---|
 | 145 |         /// @copydoc Resource::calculateSize | 
|---|
 | 146 |         size_t calculateSize(void) const; | 
|---|
 | 147 |          | 
|---|
 | 148 |         /** Check supportedness of techniques. | 
|---|
 | 149 |          */ | 
|---|
 | 150 |         void compile(); | 
|---|
 | 151 |     private: | 
|---|
 | 152 |         Techniques mTechniques; | 
|---|
 | 153 |         Techniques mSupportedTechniques; | 
|---|
 | 154 |          | 
|---|
 | 155 |         /// Compilation required | 
|---|
 | 156 |         /// This is set if the techniques change and the supportedness of techniques has to be | 
|---|
 | 157 |         /// re-evaluated. | 
|---|
 | 158 |         bool mCompilationRequired; | 
|---|
 | 159 |  | 
|---|
 | 160 |                 /** Create global rendertextures. | 
|---|
 | 161 |         */ | 
|---|
 | 162 |         void createGlobalTextures(); | 
|---|
 | 163 |          | 
|---|
 | 164 |         /** Destroy global rendertextures. | 
|---|
 | 165 |         */ | 
|---|
 | 166 |         void freeGlobalTextures(); | 
|---|
 | 167 |  | 
|---|
 | 168 |                 //TODO GSOC : These typedefs are duplicated from CompositorInstance. Solve? | 
|---|
 | 169 |                 /// Map from name->local texture | 
|---|
 | 170 |         typedef map<String,TexturePtr>::type GlobalTextureMap; | 
|---|
 | 171 |         GlobalTextureMap mGlobalTextures; | 
|---|
 | 172 |                 /// Store a list of MRTs we've created | 
|---|
 | 173 |                 typedef map<String,MultiRenderTarget*>::type GlobalMRTMap; | 
|---|
 | 174 |                 GlobalMRTMap mGlobalMRTs; | 
|---|
 | 175 |     }; | 
|---|
 | 176 |         /** @} */ | 
|---|
 | 177 |         /** @} */ | 
|---|
 | 178 | } | 
|---|
 | 179 |  | 
|---|
 | 180 | #include "OgreHeaderSuffix.h" | 
|---|
 | 181 |  | 
|---|
 | 182 | #endif | 
|---|