source: GTP/trunk/Lib/Geom/OgreStuff/include/OgreCompositor.h @ 1809

Revision 1809, 6.6 KB checked in by gumbau, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://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
32namespace 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_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
134            {
135                OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
136                OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
137                pRep = static_cast<Compositor*>(r.getPointer());
138                pUseCount = r.useCountPointer();
139                if (pUseCount)
140                {
141                    ++(*pUseCount);
142                }
143            }
144        }
145
146        /// Operator used to convert a ResourcePtr to a CompositorPtr
147        CompositorPtr& operator=(const ResourcePtr& r)
148        {
149            if (pRep == static_cast<Compositor*>(r.getPointer()))
150                return *this;
151            release();
152            // lock & copy other mutex pointer
153            OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
154            {
155                OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
156                OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
157                pRep = static_cast<Compositor*>(r.getPointer());
158                pUseCount = r.useCountPointer();
159                if (pUseCount)
160                {
161                    ++(*pUseCount);
162                }
163            }
164            return *this;
165        }
166    };
167}
168
169#endif
Note: See TracBrowser for help on using the repository browser.