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