OgreShaderSubRenderState.h
Go to the documentation of this file.
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 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderSubRenderState_
28 #define _ShaderSubRenderState_
29 
31 #include "OgreGpuProgram.h"
32 #include "OgreSceneManager.h"
33 #include "OgreMaterialSerializer.h"
34 #include "OgreScriptCompiler.h"
36 
37 
38 namespace Ogre {
39 namespace RTShader {
40 
49 
50 
57 {
58 
59 // Interface.
60 public:
61 
64 
66  virtual ~SubRenderState();
67 
68 
73  virtual const String& getType() const = 0;
74 
75 
81  virtual int getExecutionOrder() const = 0;
82 
83 
87  virtual void copyFrom(const SubRenderState& rhs) = 0;
88 
92  SubRenderState& operator= (const SubRenderState& rhs);
93 
100  virtual bool createCpuSubPrograms(ProgramSet* programSet);
101 
111  virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList) { }
112 
120  virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass) { return true; }
121 
125  SubRenderStateAccessorPtr getAccessor();
126 
130  SubRenderStateAccessorPtr getAccessor() const;
131 
132 // Protected methods
133 protected:
134 
139  virtual bool resolveParameters(ProgramSet* programSet);
140 
145  virtual bool resolveDependencies(ProgramSet* programSet);
146 
151  virtual bool addFunctionInvocations(ProgramSet* programSet);
152 
153 // Attributes.
154 private:
155  // The accessor of this instance.
157  // The accessor of the source instance which used as base to create this instance.
159 
160 };
161 
163 typedef SubRenderStateList::iterator SubRenderStateListIterator;
164 typedef SubRenderStateList::const_iterator SubRenderStateListConstIterator;
165 
167 typedef SubRenderStateSet::iterator SubRenderStateSetIterator;
168 typedef SubRenderStateSet::const_iterator SubRenderStateSetConstIterator;
169 
170 
178 {
179 public:
182  void addSubRenderStateInstance(SubRenderState* subRenderState) const
183  {
184  mSubRenderStateInstancesSet.insert(subRenderState);
185  }
186 
189  void removeSubRenderStateInstance(SubRenderState* subRenderState) const
190  {
191  SubRenderStateSetIterator itFind = mSubRenderStateInstancesSet.find(subRenderState);
192 
193  if (itFind != mSubRenderStateInstancesSet.end())
194  {
195  mSubRenderStateInstancesSet.erase(itFind);
196  }
197  }
198 
200  SubRenderStateSet& getSubRenderStateInstanceSet() { return mSubRenderStateInstancesSet; }
201 
203  const SubRenderStateSet& getSubRenderStateInstanceSet() const { return mSubRenderStateInstancesSet; }
204 
205 protected:
208  SubRenderStateAccessor(const SubRenderState* templateSubRenderState) : mTemplateSubRenderState(templateSubRenderState) {}
209 
210 
211 protected:
214 
215 private:
216  friend class SubRenderState;
217 
218 };
219 
220 
233 {
234 
235 public:
237  virtual ~SubRenderStateFactory();
238 
244  virtual const String& getType() const = 0;
245 
248  virtual SubRenderState* createInstance();
249 
258  virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator) { return NULL; }
259 
268  virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, TextureUnitState* texState, SGScriptTranslator* translator) { return NULL; }
269 
274  virtual SubRenderState* createOrRetrieveInstance(SGScriptTranslator* translator);
275 
279  virtual void destroyInstance(SubRenderState* subRenderState);
280 
283  virtual void destroyAllInstances();
284 
294  virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass) {}
295 
305  virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, const TextureUnitState* srcTextureUnit, const TextureUnitState* dstTextureUnit) {}
306 protected:
311  virtual SubRenderState* createInstanceImpl() = 0;
312 
313 // Attributes.
314 protected:
315  // List of all sub render states instances this factory created.
317 };
318 
322 }
323 }
324 
325 #endif
326 
Ogre::HashedVector< Light * >
OgreScriptCompiler.h
Ogre::AutoParamDataSource
This utility class is used to hold the information used to generate the matrices and other informatio...
Definition: OgreAutoParamDataSource.h:60
Ogre::TextureUnitState
Class representing the state of a single texture unit during a Pass of a Technique,...
Definition: OgreTextureUnitState.h:62
Ogre::RTShader::SubRenderStateSet
set< SubRenderState * >::type SubRenderStateSet
Definition: OgreShaderSubRenderState.h:166
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::SubRenderStateFactory::createInstance
virtual SubRenderState * createInstance(ScriptCompiler *compiler, PropertyAbstractNode *prop, TextureUnitState *texState, SGScriptTranslator *translator)
Create an instance of the SubRenderState based on script properties.
Definition: OgreShaderSubRenderState.h:268
Ogre::RTShader::SubRenderState
This class is the base interface of sub part from a shader based rendering pipeline.
Definition: OgreShaderSubRenderState.h:56
Ogre::RTShader::SubRenderStateListConstIterator
SubRenderStateList::const_iterator SubRenderStateListConstIterator
Definition: OgreShaderSubRenderState.h:164
Ogre::RTShader::SubRenderStateAccessor::addSubRenderStateInstance
void addSubRenderStateInstance(SubRenderState *subRenderState) const
Add SubRenderState instance to this accessor.
Definition: OgreShaderSubRenderState.h:182
OgreSceneManager.h
Ogre::RTShader::SubRenderState::updateGpuProgramsParams
virtual void updateGpuProgramsParams(Renderable *rend, Pass *pass, const AutoParamDataSource *source, const LightList *pLightList)
Update GPU programs parameters before a rendering operation occurs.
Definition: OgreShaderSubRenderState.h:111
Ogre::RTShader::SubRenderStateAccessor
This class uses as accessor from a template SubRenderState to all of its instances that created based...
Definition: OgreShaderSubRenderState.h:177
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::RTShader::SubRenderStateAccessor::mSubRenderStateInstancesSet
SubRenderStateSet mSubRenderStateInstancesSet
Definition: OgreShaderSubRenderState.h:213
Ogre::RTShader::ProgramSet
Container class for shader based programs.
Definition: OgreShaderProgramSet.h:46
Ogre::RTShader::SubRenderStateList
vector< SubRenderState * >::type SubRenderStateList
Definition: OgreShaderSubRenderState.h:162
Ogre::RTShader::SubRenderStateFactory::createInstance
virtual SubRenderState * createInstance(ScriptCompiler *compiler, PropertyAbstractNode *prop, Pass *pass, SGScriptTranslator *translator)
Create an instance of the SubRenderState based on script properties.
Definition: OgreShaderSubRenderState.h:258
OgreMaterialSerializer.h
Ogre::RTShader::SubRenderStateFactory
Abstract factory interface for creating SubRenderState implementation instances.
Definition: OgreShaderSubRenderState.h:232
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Pass
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
Ogre::RTShader::SubRenderStateAccessor::mTemplateSubRenderState
const SubRenderState * mTemplateSubRenderState
Definition: OgreShaderSubRenderState.h:212
Ogre::RTShader::SubRenderStateAccessor::removeSubRenderStateInstance
void removeSubRenderStateInstance(SubRenderState *subRenderState) const
Remove SubRenderState instance to this accessor.
Definition: OgreShaderSubRenderState.h:189
Ogre::RTShader::SubRenderStateSetIterator
SubRenderStateSet::iterator SubRenderStateSetIterator
Definition: OgreShaderSubRenderState.h:167
OgreShaderPrerequisites.h
Ogre::RTShader::SubRenderState::mThisAccessor
SubRenderStateAccessorPtr mThisAccessor
Definition: OgreShaderSubRenderState.h:156
Ogre::RTShader::SubRenderStateFactory::mSubRenderStateList
SubRenderStateSet mSubRenderStateList
Definition: OgreShaderSubRenderState.h:316
Ogre::RTShader::SubRenderStateAccessorPtr
SharedPtr< SubRenderStateAccessor > SubRenderStateAccessorPtr
Definition: OgreShaderSubRenderState.h:48
Ogre::RTShader::SubRenderStateSetConstIterator
SubRenderStateSet::const_iterator SubRenderStateSetConstIterator
Definition: OgreShaderSubRenderState.h:168
Ogre::ScriptCompiler
This is the main class for the compiler.
Definition: OgreScriptCompiler.h:188
Ogre::RTShader::RenderState
This is a container class for sub render state class.
Definition: OgreShaderRenderState.h:49
Ogre::RTShader::SubRenderStateFactory::writeInstance
virtual void writeInstance(MaterialSerializer *ser, SubRenderState *subRenderState, const TextureUnitState *srcTextureUnit, const TextureUnitState *dstTextureUnit)
Write the given sub-render state instance using the material serializer.
Definition: OgreShaderSubRenderState.h:305
Ogre::MaterialSerializer
Class for serializing Materials to / from a .material script.
Definition: OgreMaterialSerializer.h:106
Ogre::RTShader::SubRenderStateFactory::writeInstance
virtual void writeInstance(MaterialSerializer *ser, SubRenderState *subRenderState, Pass *srcPass, Pass *dstPass)
Write the given sub-render state instance using the material serializer.
Definition: OgreShaderSubRenderState.h:294
OgreShaderScriptTranslator.h
Ogre::SharedPtr< SubRenderStateAccessor >
Ogre::RTShader::SubRenderStateAccessor::getSubRenderStateInstanceSet
SubRenderStateSet & getSubRenderStateInstanceSet()
Return a set of all instances of the template SubRenderState.
Definition: OgreShaderSubRenderState.h:200
Ogre::RTShader::SubRenderStateAccessor::SubRenderStateAccessor
SubRenderStateAccessor(const SubRenderState *templateSubRenderState)
Construct SubRenderState accessor based on the given template SubRenderState.
Definition: OgreShaderSubRenderState.h:208
Ogre::RTShader::SubRenderStateListIterator
SubRenderStateList::iterator SubRenderStateListIterator
Definition: OgreShaderSubRenderState.h:163
OgreGpuProgram.h
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::RTShader::SubRenderStateFactory::SubRenderStateFactory
SubRenderStateFactory()
Definition: OgreShaderSubRenderState.h:236
Ogre::RTShader::SubRenderStateAccessor::getSubRenderStateInstanceSet
const SubRenderStateSet & getSubRenderStateInstanceSet() const
Return a set of all instances of the template SubRenderState.
Definition: OgreShaderSubRenderState.h:203
Ogre::PropertyAbstractNode
This abstract node represents a script property.
Definition: OgreScriptCompiler.h:147
Ogre::RTShader::SubRenderState::preAddToRenderState
virtual bool preAddToRenderState(const RenderState *renderState, Pass *srcPass, Pass *dstPass)
Called before adding this sub render state to the given render state.
Definition: OgreShaderSubRenderState.h:120
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::RTShader::SubRenderState::mOtherAccessor
SubRenderStateAccessorPtr mOtherAccessor
Definition: OgreShaderSubRenderState.h:158
Ogre::RTShader::SGScriptTranslator
This class responsible for translating core features of the RT Shader System for Ogre material script...
Definition: OgreShaderScriptTranslator.h:47
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15