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