Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/src/OgreCompositionPass.cpp @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 7.8 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#include "OgreStableHeaders.h"
30#include "OgreCompositionPass.h"
31#include "OgreMaterialManager.h"
32
33namespace Ogre {
34
35CompositionPass::CompositionPass(CompositionTargetPass *parent):
36    mParent(parent),
37    mType(PT_RENDERQUAD),
38        mIdentifier(0),
39        mFirstRenderQueue(RENDER_QUEUE_SKIES_EARLY),
40        mLastRenderQueue(RENDER_QUEUE_SKIES_LATE),
41    mClearBuffers(FBT_COLOUR|FBT_DEPTH),
42    mClearColour(0.0,0.0,0.0,0.0),
43        mClearDepth(1.0f),
44        mClearStencil(0),
45    mStencilCheck(false),
46    mStencilFunc(CMPF_ALWAYS_PASS),
47    mStencilRefValue(0),
48    mStencilMask(0xFFFFFFFF),
49    mStencilFailOp(SOP_KEEP),
50    mStencilDepthFailOp(SOP_KEEP),
51    mStencilPassOp(SOP_KEEP),
52    mStencilTwoSidedOperation(false)
53{
54}
55//-----------------------------------------------------------------------
56CompositionPass::~CompositionPass()
57{
58}
59//-----------------------------------------------------------------------
60void CompositionPass::setType(CompositionPass::PassType type)
61{
62    mType = type;
63}
64//-----------------------------------------------------------------------
65CompositionPass::PassType CompositionPass::getType() const
66{
67    return mType;
68}
69//-----------------------------------------------------------------------
70void CompositionPass::setIdentifier(uint32 id)
71{
72    mIdentifier = id;
73}
74//-----------------------------------------------------------------------
75uint32 CompositionPass::getIdentifier() const
76{
77    return mIdentifier;
78}
79//-----------------------------------------------------------------------
80void CompositionPass::setMaterial(const MaterialPtr& mat)
81{
82    mMaterial = mat;
83}
84//-----------------------------------------------------------------------
85void CompositionPass::setMaterialName(const String &name)
86{
87    mMaterial = MaterialManager::getSingleton().getByName(name);
88}
89//-----------------------------------------------------------------------
90const MaterialPtr& CompositionPass::getMaterial() const
91{
92    return mMaterial;
93}
94//-----------------------------------------------------------------------
95void CompositionPass::setClearBuffers(uint32 val)
96{
97    mClearBuffers = val;
98}
99//-----------------------------------------------------------------------
100uint32 CompositionPass::getClearBuffers()
101{
102    return mClearBuffers;
103}
104//-----------------------------------------------------------------------
105void CompositionPass::setClearColour(ColourValue val)
106{
107    mClearColour = val;
108}
109//-----------------------------------------------------------------------
110const ColourValue &CompositionPass::getClearColour()
111{
112    return mClearColour;
113}
114//-----------------------------------------------------------------------
115void CompositionPass::setInput(size_t id, const String &input)
116{
117    assert(id<OGRE_MAX_TEXTURE_LAYERS);
118    mInputs[id] = input;
119}
120//-----------------------------------------------------------------------
121const String &CompositionPass::getInput(size_t id)
122{
123    assert(id<OGRE_MAX_TEXTURE_LAYERS);
124    return mInputs[id];
125}
126//-----------------------------------------------------------------------
127size_t CompositionPass::getNumInputs()
128{
129    size_t count = 0;
130    for(size_t x=0; x<OGRE_MAX_TEXTURE_LAYERS; ++x)
131    {
132        if(!mInputs[x].empty())
133            count = x+1;
134    }
135    return count;
136}
137//-----------------------------------------------------------------------
138void CompositionPass::clearAllInputs()
139{
140    for(size_t x=0; x<OGRE_MAX_TEXTURE_LAYERS; ++x)
141    {
142        mInputs[x].clear();
143    }
144}
145//-----------------------------------------------------------------------
146CompositionTargetPass *CompositionPass::getParent()
147{
148    return mParent;
149}
150//-----------------------------------------------------------------------
151void CompositionPass::setFirstRenderQueue(uint8 id)
152{
153        mFirstRenderQueue = id;
154}
155//-----------------------------------------------------------------------
156uint8 CompositionPass::getFirstRenderQueue()
157{
158        return mFirstRenderQueue;
159}
160//-----------------------------------------------------------------------
161void CompositionPass::setLastRenderQueue(uint8 id)
162{
163        mLastRenderQueue = id;
164}
165//-----------------------------------------------------------------------
166uint8 CompositionPass::getLastRenderQueue()
167{
168        return mLastRenderQueue;
169}
170//-----------------------------------------------------------------------
171void CompositionPass::setClearDepth(Real depth)
172{
173        mClearDepth = depth;
174}
175Real CompositionPass::getClearDepth()
176{
177        return mClearDepth;
178}
179void CompositionPass::setClearStencil(uint32 value)
180{
181        mClearStencil = value;
182}
183uint32 CompositionPass::getClearStencil()
184{
185        return mClearStencil;
186}
187
188void CompositionPass::setStencilCheck(bool value)
189{
190        mStencilCheck = value;
191}
192bool CompositionPass::getStencilCheck()
193{
194        return mStencilCheck;
195}
196void CompositionPass::setStencilFunc(CompareFunction value)
197{
198        mStencilFunc = value;
199}
200CompareFunction CompositionPass::getStencilFunc()
201{
202        return mStencilFunc;
203} 
204void CompositionPass::setStencilRefValue(uint32 value)
205{
206        mStencilRefValue = value;
207}
208uint32 CompositionPass::getStencilRefValue()
209{
210        return mStencilRefValue;
211}
212void CompositionPass::setStencilMask(uint32 value)
213{
214        mStencilMask = value;
215}
216uint32 CompositionPass::getStencilMask()
217{
218        return mStencilMask;
219}
220void CompositionPass::setStencilFailOp(StencilOperation value)
221{
222        mStencilFailOp = value;
223}
224StencilOperation CompositionPass::getStencilFailOp()
225{
226        return mStencilFailOp;
227}
228void CompositionPass::setStencilDepthFailOp(StencilOperation value)
229{
230        mStencilDepthFailOp = value;
231}
232StencilOperation CompositionPass::getStencilDepthFailOp()
233{
234        return mStencilDepthFailOp;
235}
236void CompositionPass::setStencilPassOp(StencilOperation value)
237{
238        mStencilPassOp = value;
239}
240StencilOperation CompositionPass::getStencilPassOp()
241{
242        return mStencilPassOp;
243}
244void CompositionPass::setStencilTwoSidedOperation(bool value)
245{
246        mStencilTwoSidedOperation = value;
247}
248bool CompositionPass::getStencilTwoSidedOperation()
249{
250        return mStencilTwoSidedOperation;
251}
252
253//-----------------------------------------------------------------------
254bool CompositionPass::_isSupported(void)
255{
256    // A pass is supported if material referenced have a supported technique
257
258    if (mType == PT_RENDERQUAD)
259    {
260        if (mMaterial.isNull())
261        {
262            return false;
263        }
264
265        mMaterial->compile();
266        if (mMaterial->getNumSupportedTechniques() == 0)
267        {
268            return false;
269        }
270    }
271
272    return true;
273}
274
275}
Note: See TracBrowser for help on using the repository browser.