OgreShaderSubRenderState.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _ShaderSubRenderState_
#define _ShaderSubRenderState_
#include "OgreShaderPrerequisites.h"
#include "OgreGpuProgram.h"
#include "OgreSceneManager.h"
#include "OgreMaterialSerializer.h"
#include "OgreScriptCompiler.h"
#include "OgreShaderScriptTranslator.h"
namespace Ogre {
namespace RTShader {
typedef SharedPtr<SubRenderStateAccessor> SubRenderStateAccessorPtr;
class _OgreRTSSExport SubRenderState : public RTShaderSystemAlloc
{
// Interface.
public:
SubRenderState();
virtual ~SubRenderState();
virtual const String& getType() const = 0;
virtual int getExecutionOrder() const = 0;
virtual void copyFrom(const SubRenderState& rhs) = 0;
SubRenderState& operator= (const SubRenderState& rhs);
virtual bool createCpuSubPrograms(ProgramSet* programSet);
virtual void updateGpuProgramsParams(Renderable* rend, Pass* pass, const AutoParamDataSource* source, const LightList* pLightList) { }
virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass) { return true; }
SubRenderStateAccessorPtr getAccessor();
SubRenderStateAccessorPtr getAccessor() const;
// Protected methods
protected:
virtual bool resolveParameters(ProgramSet* programSet);
virtual bool resolveDependencies(ProgramSet* programSet);
virtual bool addFunctionInvocations(ProgramSet* programSet);
// Attributes.
private:
// The accessor of this instance.
mutable SubRenderStateAccessorPtr mThisAccessor;
// The accessor of the source instance which used as base to create this instance.
SubRenderStateAccessorPtr mOtherAccessor;
};
typedef vector<SubRenderState*>::type SubRenderStateList;
typedef SubRenderStateList::iterator SubRenderStateListIterator;
typedef SubRenderStateList::const_iterator SubRenderStateListConstIterator;
typedef set<SubRenderState*>::type SubRenderStateSet;
typedef SubRenderStateSet::iterator SubRenderStateSetIterator;
typedef SubRenderStateSet::const_iterator SubRenderStateSetConstIterator;
class _OgreRTSSExport SubRenderStateAccessor
{
public:
void addSubRenderStateInstance(SubRenderState* subRenderState) const
{
mSubRenderStateInstancesSet.insert(subRenderState);
}
void removeSubRenderStateInstance(SubRenderState* subRenderState) const
{
SubRenderStateSetIterator itFind = mSubRenderStateInstancesSet.find(subRenderState);
if (itFind != mSubRenderStateInstancesSet.end())
{
mSubRenderStateInstancesSet.erase(itFind);
}
}
SubRenderStateSet& getSubRenderStateInstanceSet() { return mSubRenderStateInstancesSet; }
const SubRenderStateSet& getSubRenderStateInstanceSet() const { return mSubRenderStateInstancesSet; }
protected:
SubRenderStateAccessor(const SubRenderState* templateSubRenderState) : mTemplateSubRenderState(templateSubRenderState) {}
protected:
const SubRenderState* mTemplateSubRenderState;
mutable SubRenderStateSet mSubRenderStateInstancesSet;
private:
friend class SubRenderState;
};
class _OgreRTSSExport SubRenderStateFactory : public RTShaderSystemAlloc
{
public:
SubRenderStateFactory() {}
virtual ~SubRenderStateFactory();
virtual const String& getType() const = 0;
virtual SubRenderState* createInstance();
virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator) { return NULL; }
virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, TextureUnitState* texState, SGScriptTranslator* translator) { return NULL; }
virtual SubRenderState* createOrRetrieveInstance(SGScriptTranslator* translator);
virtual void destroyInstance(SubRenderState* subRenderState);
virtual void destroyAllInstances();
virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass) {}
virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, const TextureUnitState* srcTextureUnit, const TextureUnitState* dstTextureUnit) {}
protected:
virtual SubRenderState* createInstanceImpl() = 0;
// Attributes.
protected:
// List of all sub render states instances this factory created.
SubRenderStateSet mSubRenderStateList;
};
}
}
#endif
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::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::MaterialSerializer
Class for serializing Materials to / from a .material script.
Definition: OgreMaterialSerializer.h:106
Ogre::Pass
Class defining a single pass of a Technique (of a Material), i.e.
Definition: OgrePass.h:80
Ogre::RTShader::SubRenderStateSet
set< SubRenderState * >::type SubRenderStateSet
Definition: OgreShaderSubRenderState.h:166
Ogre::RTShader::SubRenderState
This class is the base interface of sub part from a shader based rendering pipeline.
Definition: OgreShaderSubRenderState.h:56
Ogre::RTShader::SubRenderStateAccessor::addSubRenderStateInstance
void addSubRenderStateInstance(SubRenderState *subRenderState) const
Add SubRenderState instance to this accessor.
Definition: OgreShaderSubRenderState.h:182
Ogre::RTShader::SubRenderStateListConstIterator
SubRenderStateList::const_iterator SubRenderStateListConstIterator
Definition: OgreShaderSubRenderState.h:164
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
Ogre::RTShader::SubRenderStateList
vector< SubRenderState * >::type SubRenderStateList
Definition: OgreShaderSubRenderState.h:162
OgreScriptCompiler.h
Ogre::RTShader::SubRenderStateAccessor::getSubRenderStateInstanceSet
SubRenderStateSet & getSubRenderStateInstanceSet()
Return a set of all instances of the template SubRenderState.
Definition: OgreShaderSubRenderState.h:200
OgreShaderPrerequisites.h
Ogre::RTShader::SubRenderStateSetIterator
SubRenderStateSet::iterator SubRenderStateSetIterator
Definition: OgreShaderSubRenderState.h:167
Ogre::RTShader::SubRenderStateFactory::mSubRenderStateList
SubRenderStateSet mSubRenderStateList
Definition: OgreShaderSubRenderState.h:316
Ogre::RTShader::SubRenderStateAccessorPtr
SharedPtr< SubRenderStateAccessor > SubRenderStateAccessorPtr
Definition: OgreShaderSubRenderState.h:48
Ogre::RTShader::SubRenderStateAccessor::mTemplateSubRenderState
const SubRenderState * mTemplateSubRenderState
Definition: OgreShaderSubRenderState.h:212
Ogre::RTShader::ProgramSet
Container class for shader based programs.
Definition: OgreShaderProgramSet.h:46
Ogre::RTShader::SubRenderStateSetConstIterator
SubRenderStateSet::const_iterator SubRenderStateSetConstIterator
Definition: OgreShaderSubRenderState.h:168
Ogre::TextureUnitState
Class representing the state of a single texture unit during a Pass of a Technique, of a Material.
Definition: OgreTextureUnitState.h:62
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::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, Pass *srcPass, Pass *dstPass)
Write the given sub-render state instance using the material serializer.
Definition: OgreShaderSubRenderState.h:294
Ogre::RTShader::SGScriptTranslator
This class responsible for translating core features of the RT Shader System for Ogre material script...
Definition: OgreShaderScriptTranslator.h:47
Ogre::RTShader::SubRenderState::mOtherAccessor
SubRenderStateAccessorPtr mOtherAccessor
Definition: OgreShaderSubRenderState.h:158
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::PropertyAbstractNode
This abstract node represents a script property.
Definition: OgreScriptCompiler.h:147
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::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::RTShader::SubRenderStateFactory::SubRenderStateFactory
SubRenderStateFactory()
Definition: OgreShaderSubRenderState.h:236
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
OgreSceneManager.h
Ogre::RTShader::SubRenderStateAccessor::SubRenderStateAccessor
SubRenderStateAccessor(const SubRenderState *templateSubRenderState)
Construct SubRenderState accessor based on the given template SubRenderState.
Definition: OgreShaderSubRenderState.h:208
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108
Ogre::RTShader::SubRenderStateAccessor::mSubRenderStateInstancesSet
SubRenderStateSet mSubRenderStateInstancesSet
Definition: OgreShaderSubRenderState.h:213
Ogre::RTShader::SubRenderStateFactory
Abstract factory interface for creating SubRenderState implementation instances.
Definition: OgreShaderSubRenderState.h:232
OgreShaderScriptTranslator.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::SubRenderStateListIterator
SubRenderStateList::iterator SubRenderStateListIterator
Definition: OgreShaderSubRenderState.h:163
Ogre::SharedPtr< SubRenderStateAccessor >
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::RTShader::SubRenderStateAccessor::getSubRenderStateInstanceSet
const SubRenderStateSet & getSubRenderStateInstanceSet() const
Return a set of all instances of the template SubRenderState.
Definition: OgreShaderSubRenderState.h:203
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::RTShader::SubRenderState::mThisAccessor
SubRenderStateAccessorPtr mThisAccessor
Definition: OgreShaderSubRenderState.h:156
OgreMaterialSerializer.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::RTShader::SubRenderStateAccessor::removeSubRenderStateInstance
void removeSubRenderStateInstance(SubRenderState *subRenderState) const
Remove SubRenderState instance to this accessor.
Definition: OgreShaderSubRenderState.h:189
OgreGpuProgram.h
Ogre::ScriptCompiler
This is the main class for the compiler.
Definition: OgreScriptCompiler.h:188
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.