OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 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 
32 
33 namespace Ogre {
34 namespace RTShader {
35 
44 
45 
52 {
53 
54 // Interface.
55 public:
56 
59 
61  virtual ~SubRenderState();
62 
63 
68  virtual const String& getType() const = 0;
69 
70 
76  virtual int getExecutionOrder() const = 0;
77 
78 
82  virtual void copyFrom(const SubRenderState& rhs) = 0;
83 
87  SubRenderState& operator= (const SubRenderState& rhs);
88 
95  virtual bool createCpuSubPrograms(ProgramSet* programSet);
96 
106  virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList) { }
107 
115  virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass) { return true; }
116 
120  SubRenderStateAccessorPtr getAccessor();
121 
125  SubRenderStateAccessorPtr getAccessor() const;
126 
127 // Protected methods
128 protected:
129 
134  virtual bool resolveParameters(ProgramSet* programSet);
135 
140  virtual bool resolveDependencies(ProgramSet* programSet);
141 
146  virtual bool addFunctionInvocations(ProgramSet* programSet);
147 
148 // Attributes.
149 private:
150  // The accessor of this instance.
152  // The accessor of the source instance which used as base to create this instance.
154 
155 };
156 
158 typedef SubRenderStateList::iterator SubRenderStateListIterator;
159 typedef SubRenderStateList::const_iterator SubRenderStateListConstIterator;
160 
162 typedef SubRenderStateSet::iterator SubRenderStateSetIterator;
163 typedef SubRenderStateSet::const_iterator SubRenderStateSetConstIterator;
164 
165 
173 {
174 public:
177  void addSubRenderStateInstance(SubRenderState* subRenderState) const
178  {
179  mSubRenderStateInstancesSet.insert(subRenderState);
180  }
181 
184  void removeSubRenderStateInstance(SubRenderState* subRenderState) const
185  {
186  SubRenderStateSetIterator itFind = mSubRenderStateInstancesSet.find(subRenderState);
187 
188  if (itFind != mSubRenderStateInstancesSet.end())
189  {
190  mSubRenderStateInstancesSet.erase(itFind);
191  }
192  }
193 
195  SubRenderStateSet& getSubRenderStateInstanceSet() { return mSubRenderStateInstancesSet; }
196 
198  const SubRenderStateSet& getSubRenderStateInstanceSet() const { return mSubRenderStateInstancesSet; }
199 
200 protected:
203  SubRenderStateAccessor(const SubRenderState* templateSubRenderState) : mTemplateSubRenderState(templateSubRenderState) {}
204 
205 
206 protected:
209 
210 private:
211  friend class SubRenderState;
212 
213 };
214 
215 
228 {
229 
230 public:
232  virtual ~SubRenderStateFactory();
233 
239  virtual const String& getType() const = 0;
240 
243  virtual SubRenderState* createInstance();
244 
253  virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator) { return NULL; }
254 
263  virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, TextureUnitState* texState, SGScriptTranslator* translator) { return NULL; }
264 
269  virtual SubRenderState* createOrRetrieveInstance(SGScriptTranslator* translator);
270 
274  virtual void destroyInstance(SubRenderState* subRenderState);
275 
278  virtual void destroyAllInstances();
279 
289  virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass) {}
290 
300  virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, const TextureUnitState* srcTextureUnit, const TextureUnitState* dstTextureUnit) {}
301 protected:
306  virtual SubRenderState* createInstanceImpl() = 0;
307 
308 // Attributes.
309 protected:
310  // List of all sub render states instances this factory created.
312 };
313 
317 }
318 }
319 
320 #endif
321 
SubRenderStateList::const_iterator SubRenderStateListConstIterator
SharedPtr< SubRenderStateAccessor > SubRenderStateAccessorPtr
virtual void updateGpuProgramsParams(Renderable *rend, Pass *pass, const AutoParamDataSource *source, const LightList *pLightList)
Update GPU programs parameters before a rendering operation occurs.
const SubRenderStateSet & getSubRenderStateInstanceSet() const
Return a set of all instances of the template SubRenderState.
#define _OgreRTSSExport
This class uses as accessor from a template SubRenderState to all of its instances that created based...
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:78
Abstract class defining the interface all renderable objects must implement.
virtual SubRenderState * createInstance(ScriptCompiler *compiler, PropertyAbstractNode *prop, Pass *pass, SGScriptTranslator *translator)
Create an instance of the SubRenderState based on script properties.
Class for serializing Materials to / from a .material script.
Abstract factory interface for creating SubRenderState implementation instances.
This abstract node represents a script property.
This is a container class for sub render state class.
SubRenderStateAccessor(const SubRenderState *templateSubRenderState)
Construct SubRenderState accessor based on the given template SubRenderState.
This class responsible for translating core features of the RT Shader System for Ogre material script...
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
SubRenderStateAccessorPtr mOtherAccessor
SubRenderStateSet::iterator SubRenderStateSetIterator
SubRenderStateSet::const_iterator SubRenderStateSetConstIterator
virtual SubRenderState * createInstance(ScriptCompiler *compiler, PropertyAbstractNode *prop, TextureUnitState *texState, SGScriptTranslator *translator)
Create an instance of the SubRenderState based on script properties.
vector< SubRenderState * >::type SubRenderStateList
SubRenderStateSet & getSubRenderStateInstanceSet()
Return a set of all instances of the template SubRenderState.
void addSubRenderStateInstance(SubRenderState *subRenderState) const
Add SubRenderState instance to this accessor.
This class is the base interface of sub part from a shader based rendering pipeline.
set< SubRenderState * >::type SubRenderStateSet
SubRenderStateList::iterator SubRenderStateListIterator
_StringBase String
Definition: OgreCommon.h:53
This is the main class for the compiler.
Container class for shader based programs.
virtual void writeInstance(MaterialSerializer *ser, SubRenderState *subRenderState, const TextureUnitState *srcTextureUnit, const TextureUnitState *dstTextureUnit)
Write the given sub-render state instance using the material serializer.
SubRenderStateAccessorPtr mThisAccessor
virtual bool preAddToRenderState(const RenderState *renderState, Pass *srcPass, Pass *dstPass)
Called before adding this sub render state to the given render state.
void removeSubRenderStateInstance(SubRenderState *subRenderState) const
Remove SubRenderState instance to this accessor.
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
virtual void writeInstance(MaterialSerializer *ser, SubRenderState *subRenderState, Pass *srcPass, Pass *dstPass)
Write the given sub-render state instance using the material serializer.
This utility class is used to hold the information used to generate the matrices and other informatio...