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 __CompositionTechnique_H__ |
---|
29 | #define __CompositionTechnique_H__ |
---|
30 | |
---|
31 | #include "OgrePrerequisites.h" |
---|
32 | #include "OgrePixelFormat.h" |
---|
33 | #include "OgreIteratorWrappers.h" |
---|
34 | #include "OgreHeaderPrefix.h" |
---|
35 | |
---|
36 | namespace Ogre { |
---|
37 | /** \addtogroup Core |
---|
38 | * @{ |
---|
39 | */ |
---|
40 | /** \addtogroup Effects |
---|
41 | * @{ |
---|
42 | */ |
---|
43 | /** Base composition technique, can be subclassed in plugins. |
---|
44 | */ |
---|
45 | class _OgreExport CompositionTechnique : public CompositorInstAlloc |
---|
46 | { |
---|
47 | public: |
---|
48 | CompositionTechnique(Compositor *parent); |
---|
49 | virtual ~CompositionTechnique(); |
---|
50 | |
---|
51 | //The scope of a texture defined by the compositor |
---|
52 | enum TextureScope { |
---|
53 | //Local texture - only available to the compositor passes in this technique |
---|
54 | TS_LOCAL, |
---|
55 | //Chain texture - available to the other compositors in the chain |
---|
56 | TS_CHAIN, |
---|
57 | //Global texture - available to everyone in every scope |
---|
58 | TS_GLOBAL |
---|
59 | }; |
---|
60 | |
---|
61 | /// Local texture definition |
---|
62 | class TextureDefinition : public CompositorInstAlloc |
---|
63 | { |
---|
64 | public: |
---|
65 | String name; |
---|
66 | //Texture definition being a reference is determined by these two fields not being empty. |
---|
67 | String refCompName; //If a reference, the name of the compositor being referenced |
---|
68 | String refTexName; //If a reference, the name of the texture in the compositor being referenced |
---|
69 | size_t width; // 0 means adapt to target width |
---|
70 | size_t height; // 0 means adapt to target height |
---|
71 | float widthFactor; // multiple of target width to use (if width = 0) |
---|
72 | float heightFactor; // multiple of target height to use (if height = 0) |
---|
73 | PixelFormatList formatList; // more than one means MRT |
---|
74 | bool fsaa; // FSAA enabled; true = determine from main target (if render_scene), false = disable |
---|
75 | bool hwGammaWrite; // Do sRGB gamma correction on write (only 8-bit per channel formats) |
---|
76 | uint16 depthBufferId;//Depth Buffer's pool ID. (unrelated to "pool" variable below) |
---|
77 | bool pooled; // whether to use pooled textures for this one |
---|
78 | TextureScope scope; // Which scope has access to this texture |
---|
79 | |
---|
80 | TextureDefinition() :width(0), height(0), widthFactor(1.0f), heightFactor(1.0f), |
---|
81 | fsaa(true), hwGammaWrite(false), depthBufferId(1), pooled(false), scope(TS_LOCAL) {} |
---|
82 | }; |
---|
83 | /// Typedefs for several iterators |
---|
84 | typedef vector<CompositionTargetPass *>::type TargetPasses; |
---|
85 | typedef VectorIterator<TargetPasses> TargetPassIterator; |
---|
86 | typedef vector<TextureDefinition*>::type TextureDefinitions; |
---|
87 | typedef VectorIterator<TextureDefinitions> TextureDefinitionIterator; |
---|
88 | |
---|
89 | /** Create a new local texture definition, and return a pointer to it. |
---|
90 | @param name Name of the local texture |
---|
91 | */ |
---|
92 | TextureDefinition *createTextureDefinition(const String &name); |
---|
93 | |
---|
94 | /** Remove and destroy a local texture definition. |
---|
95 | */ |
---|
96 | void removeTextureDefinition(size_t idx); |
---|
97 | |
---|
98 | /** Get a local texture definition. |
---|
99 | */ |
---|
100 | TextureDefinition *getTextureDefinition(size_t idx); |
---|
101 | |
---|
102 | /** Get a local texture definition with a specific name. |
---|
103 | */ |
---|
104 | TextureDefinition *getTextureDefinition(const String& name); |
---|
105 | |
---|
106 | /** Get the number of local texture definitions. |
---|
107 | */ |
---|
108 | size_t getNumTextureDefinitions(); |
---|
109 | |
---|
110 | /** Remove all Texture Definitions |
---|
111 | */ |
---|
112 | void removeAllTextureDefinitions(); |
---|
113 | |
---|
114 | /** Get an iterator over the TextureDefinitions in this Technique. */ |
---|
115 | TextureDefinitionIterator getTextureDefinitionIterator(void); |
---|
116 | |
---|
117 | /** Create a new target pass, and return a pointer to it. |
---|
118 | */ |
---|
119 | CompositionTargetPass *createTargetPass(); |
---|
120 | |
---|
121 | /** Remove a target pass. It will also be destroyed. |
---|
122 | */ |
---|
123 | void removeTargetPass(size_t idx); |
---|
124 | |
---|
125 | /** Get a target pass. |
---|
126 | */ |
---|
127 | CompositionTargetPass *getTargetPass(size_t idx); |
---|
128 | |
---|
129 | /** Get the number of target passes. |
---|
130 | */ |
---|
131 | size_t getNumTargetPasses(); |
---|
132 | |
---|
133 | /** Remove all target passes. |
---|
134 | */ |
---|
135 | void removeAllTargetPasses(); |
---|
136 | |
---|
137 | /** Get an iterator over the TargetPasses in this Technique. */ |
---|
138 | TargetPassIterator getTargetPassIterator(void); |
---|
139 | |
---|
140 | /** Get output (final) target pass |
---|
141 | */ |
---|
142 | CompositionTargetPass *getOutputTargetPass(); |
---|
143 | |
---|
144 | /** Determine if this technique is supported on the current rendering device. |
---|
145 | @param allowTextureDegradation True to accept a reduction in texture depth |
---|
146 | */ |
---|
147 | virtual bool isSupported(bool allowTextureDegradation); |
---|
148 | |
---|
149 | /** Assign a scheme name to this technique, used to switch between |
---|
150 | multiple techniques by choice rather than for hardware compatibility. |
---|
151 | */ |
---|
152 | virtual void setSchemeName(const String& schemeName); |
---|
153 | /** Get the scheme name assigned to this technique. */ |
---|
154 | const String& getSchemeName() const { return mSchemeName; } |
---|
155 | |
---|
156 | /** Set the name of the compositor logic assigned to this technique. |
---|
157 | Instances of this technique will be auto-coupled with the matching logic. |
---|
158 | */ |
---|
159 | void setCompositorLogicName(const String& compositorLogicName) |
---|
160 | { mCompositorLogicName = compositorLogicName; } |
---|
161 | /** Get the compositor logic name assigned to this technique */ |
---|
162 | const String& getCompositorLogicName() const { return mCompositorLogicName; } |
---|
163 | |
---|
164 | /** Get parent object */ |
---|
165 | Compositor *getParent(); |
---|
166 | private: |
---|
167 | /// Parent compositor |
---|
168 | Compositor *mParent; |
---|
169 | /// Local texture definitions |
---|
170 | TextureDefinitions mTextureDefinitions; |
---|
171 | |
---|
172 | /// Intermediate target passes |
---|
173 | TargetPasses mTargetPasses; |
---|
174 | /// Output target pass (can be only one) |
---|
175 | CompositionTargetPass *mOutputTarget; |
---|
176 | |
---|
177 | /// Optional scheme name |
---|
178 | String mSchemeName; |
---|
179 | |
---|
180 | /// Optional compositor logic name |
---|
181 | String mCompositorLogicName; |
---|
182 | |
---|
183 | }; |
---|
184 | /** @} */ |
---|
185 | /** @} */ |
---|
186 | |
---|
187 | } |
---|
188 | |
---|
189 | #include "OgreHeaderSuffix.h" |
---|
190 | |
---|
191 | #endif |
---|