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 __Compositor_H__ |
---|
30 | #define __Compositor_H__ |
---|
31 | |
---|
32 | #include "OgrePrerequisites.h" |
---|
33 | #include "OgreIteratorWrappers.h" |
---|
34 | #include "OgreResource.h" |
---|
35 | |
---|
36 | namespace Ogre { |
---|
37 | /** Class representing a Compositor object. Compositors provide the means |
---|
38 | to flexibly "composite" the final rendering result from multiple scene renders |
---|
39 | and intermediate operations like rendering fullscreen quads. This makes |
---|
40 | it possible to apply postfilter effects, HDRI postprocessing, and shadow |
---|
41 | effects to a Viewport. |
---|
42 | */ |
---|
43 | class _OgreExport Compositor: public Resource |
---|
44 | { |
---|
45 | public: |
---|
46 | Compositor(ResourceManager* creator, const String& name, ResourceHandle handle, |
---|
47 | const String& group, bool isManual = false, ManualResourceLoader* loader = 0); |
---|
48 | ~Compositor(); |
---|
49 | |
---|
50 | /// Data types for internal lists |
---|
51 | typedef std::vector<CompositionTechnique *> Techniques; |
---|
52 | typedef VectorIterator<Techniques> TechniqueIterator; |
---|
53 | |
---|
54 | /** Create a new technique, and return a pointer to it. |
---|
55 | */ |
---|
56 | CompositionTechnique *createTechnique(); |
---|
57 | |
---|
58 | /** Remove a technique. It will also be destroyed. |
---|
59 | */ |
---|
60 | void removeTechnique(size_t idx); |
---|
61 | |
---|
62 | /** Get a technique. |
---|
63 | */ |
---|
64 | CompositionTechnique *getTechnique(size_t idx); |
---|
65 | |
---|
66 | /** Get the number of techniques. |
---|
67 | */ |
---|
68 | size_t getNumTechniques(); |
---|
69 | |
---|
70 | /** Remove all techniques |
---|
71 | */ |
---|
72 | void removeAllTechniques(); |
---|
73 | |
---|
74 | /** Get an iterator over the Techniques in this compositor. */ |
---|
75 | TechniqueIterator getTechniqueIterator(void); |
---|
76 | |
---|
77 | /** Get a supported technique. |
---|
78 | @remarks |
---|
79 | The supported technique list is only available after this compositor has been compiled, |
---|
80 | which typically happens on loading it. Therefore, if this method returns |
---|
81 | an empty list, try calling Compositor::load. |
---|
82 | */ |
---|
83 | CompositionTechnique *getSupportedTechnique(size_t idx); |
---|
84 | |
---|
85 | /** Get the number of supported techniques. |
---|
86 | @remarks |
---|
87 | The supported technique list is only available after this compositor has been compiled, |
---|
88 | which typically happens on loading it. Therefore, if this method returns |
---|
89 | an empty list, try calling Compositor::load. |
---|
90 | */ |
---|
91 | size_t getNumSupportedTechniques(); |
---|
92 | |
---|
93 | /** Gets an iterator over all the Techniques which are supported by the current card. |
---|
94 | @remarks |
---|
95 | The supported technique list is only available after this compositor has been compiled, |
---|
96 | which typically happens on loading it. Therefore, if this method returns |
---|
97 | an empty list, try calling Compositor::load. |
---|
98 | */ |
---|
99 | TechniqueIterator getSupportedTechniqueIterator(void); |
---|
100 | protected: |
---|
101 | /// @copydoc Resource::loadImpl |
---|
102 | void loadImpl(void); |
---|
103 | |
---|
104 | /// @copydoc Resource::unloadImpl |
---|
105 | void unloadImpl(void); |
---|
106 | /// @copydoc Resource::calculateSize |
---|
107 | size_t calculateSize(void) const; |
---|
108 | |
---|
109 | /** Check supportedness of techniques. |
---|
110 | */ |
---|
111 | void compile(); |
---|
112 | private: |
---|
113 | Techniques mTechniques; |
---|
114 | Techniques mSupportedTechniques; |
---|
115 | |
---|
116 | /// Compilation required |
---|
117 | /// This is set if the techniques change and the supportedness of techniques has to be |
---|
118 | /// re-evaluated. |
---|
119 | bool mCompilationRequired; |
---|
120 | }; |
---|
121 | |
---|
122 | /** Specialisation of SharedPtr to allow SharedPtr to be assigned to CompositorPtr |
---|
123 | @note Has to be a subclass since we need operator=. |
---|
124 | We could templatise this instead of repeating per Resource subclass, |
---|
125 | except to do so requires a form VC6 does not support i.e. |
---|
126 | ResourceSubclassPtr<T> : public SharedPtr<T> |
---|
127 | */ |
---|
128 | class _OgreExport CompositorPtr : public SharedPtr<Compositor> |
---|
129 | { |
---|
130 | public: |
---|
131 | CompositorPtr() : SharedPtr<Compositor>() {} |
---|
132 | explicit CompositorPtr(Compositor* rep) : SharedPtr<Compositor>(rep) {} |
---|
133 | CompositorPtr(const CompositorPtr& r) : SharedPtr<Compositor>(r) {} |
---|
134 | CompositorPtr(const ResourcePtr& r) : SharedPtr<Compositor>() |
---|
135 | { |
---|
136 | // lock & copy other mutex pointer |
---|
137 | OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) |
---|
138 | { |
---|
139 | OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) |
---|
140 | OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) |
---|
141 | pRep = static_cast<Compositor*>(r.getPointer()); |
---|
142 | pUseCount = r.useCountPointer(); |
---|
143 | if (pUseCount) |
---|
144 | { |
---|
145 | ++(*pUseCount); |
---|
146 | } |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | /// Operator used to convert a ResourcePtr to a CompositorPtr |
---|
151 | CompositorPtr& operator=(const ResourcePtr& r) |
---|
152 | { |
---|
153 | if (pRep == static_cast<Compositor*>(r.getPointer())) |
---|
154 | return *this; |
---|
155 | release(); |
---|
156 | // lock & copy other mutex pointer |
---|
157 | OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME) |
---|
158 | { |
---|
159 | OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME) |
---|
160 | OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME) |
---|
161 | pRep = static_cast<Compositor*>(r.getPointer()); |
---|
162 | pUseCount = r.useCountPointer(); |
---|
163 | if (pUseCount) |
---|
164 | { |
---|
165 | ++(*pUseCount); |
---|
166 | } |
---|
167 | } |
---|
168 | else |
---|
169 | { |
---|
170 | // RHS must be a null pointer |
---|
171 | assert(r.isNull() && "RHS must be null if it has no mutex!"); |
---|
172 | setNull(); |
---|
173 | } |
---|
174 | return *this; |
---|
175 | } |
---|
176 | }; |
---|
177 | } |
---|
178 | |
---|
179 | #endif |
---|