| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- #include "CmPass.h"
- #include "CmPassRTTI.h"
- #include "CmException.h"
- namespace CamelotEngine
- {
- //-----------------------------------------------------------------------------
- Pass::Pass()
- : mSourceBlendFactor(SBF_ONE)
- , mDestBlendFactor(SBF_ZERO)
- , mSourceBlendFactorAlpha(SBF_ONE)
- , mDestBlendFactorAlpha(SBF_ZERO)
- , mSeparateBlend(false)
- , mBlendOperation(SBO_ADD)
- , mAlphaBlendOperation(SBO_ADD)
- , mSeparateBlendOperation(false)
- , mDepthCheck(true)
- , mDepthWrite(true)
- , mDepthFunc(CMPF_LESS_EQUAL)
- , mDepthBiasConstant(0.0f)
- , mDepthBiasSlopeScale(0.0f)
- , mDepthBiasPerIteration(0.0f)
- , mColourWrite(true)
- , mAlphaRejectFunc(CMPF_ALWAYS_PASS)
- , mAlphaRejectVal(0)
- , mAlphaToCoverageEnabled(false)
- , mCullMode(CULL_CLOCKWISE)
- , mPolygonMode(PM_SOLID)
- , mPointSize(1.0f)
- , mPointMinSize(0.0f)
- , mPointMaxSize(0.0f)
- {
- }
- //-----------------------------------------------------------------------------
- Pass::Pass(const Pass& oth)
- {
- *this = oth;
- }
- //-----------------------------------------------------------------------------
- Pass::~Pass()
- {
-
- }
- //-----------------------------------------------------------------------------
- Pass& Pass::operator=(const Pass& oth)
- {
- // Default blending (overwrite)
- mSourceBlendFactor = oth.mSourceBlendFactor;
- mDestBlendFactor = oth.mDestBlendFactor;
- mSourceBlendFactorAlpha = oth.mSourceBlendFactorAlpha;
- mDestBlendFactorAlpha = oth.mDestBlendFactorAlpha;
- mSeparateBlend = oth.mSeparateBlend;
- mBlendOperation = oth.mBlendOperation;
- mAlphaBlendOperation = oth.mAlphaBlendOperation;
- mSeparateBlendOperation = oth.mSeparateBlendOperation;
- mDepthCheck = oth.mDepthCheck;
- mDepthWrite = oth.mDepthWrite;
- mAlphaRejectFunc = oth.mAlphaRejectFunc;
- mAlphaRejectVal = oth.mAlphaRejectVal;
- mAlphaToCoverageEnabled = oth.mAlphaToCoverageEnabled;
- mColourWrite = oth.mColourWrite;
- mDepthFunc = oth.mDepthFunc;
- mDepthBiasConstant = oth.mDepthBiasConstant;
- mDepthBiasSlopeScale = oth.mDepthBiasSlopeScale;
- mDepthBiasPerIteration = oth.mDepthBiasPerIteration;
- mCullMode = oth.mCullMode;
- mPolygonMode = oth.mPolygonMode;
- mPointSize = oth.mPointSize;
- mPointMinSize = oth.mPointMinSize;
- mPointMaxSize = oth.mPointMaxSize;
- mVertexProgram = oth.mVertexProgram;
- mFragmentProgram = oth.mFragmentProgram;
- mGeometryProgram = oth.mGeometryProgram;
- return *this;
- }
- //-----------------------------------------------------------------------
- void Pass::setPointSize(float ps)
- {
- mPointSize = ps;
- }
- //-----------------------------------------------------------------------
- void Pass::setPointMinSize(float min)
- {
- mPointMinSize = min;
- }
- //-----------------------------------------------------------------------
- float Pass::getPointMinSize(void) const
- {
- return mPointMinSize;
- }
- //-----------------------------------------------------------------------
- void Pass::setPointMaxSize(float max)
- {
- mPointMaxSize = max;
- }
- //-----------------------------------------------------------------------
- float Pass::getPointMaxSize(void) const
- {
- return mPointMaxSize;
- }
- //-----------------------------------------------------------------------
- float Pass::getPointSize(void) const
- {
- return mPointSize;
- }
- //-----------------------------------------------------------------------
- void Pass::setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor)
- {
- mSourceBlendFactor = sourceFactor;
- mDestBlendFactor = destFactor;
- mSeparateBlend = false;
- }
- //-----------------------------------------------------------------------
- void Pass::setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha )
- {
- mSourceBlendFactor = sourceFactor;
- mDestBlendFactor = destFactor;
- mSourceBlendFactorAlpha = sourceFactorAlpha;
- mDestBlendFactorAlpha = destFactorAlpha;
- mSeparateBlend = true;
- }
- //-----------------------------------------------------------------------
- SceneBlendFactor Pass::getSourceBlendFactor(void) const
- {
- return mSourceBlendFactor;
- }
- //-----------------------------------------------------------------------
- SceneBlendFactor Pass::getDestBlendFactor(void) const
- {
- return mDestBlendFactor;
- }
- //-----------------------------------------------------------------------
- SceneBlendFactor Pass::getSourceBlendFactorAlpha(void) const
- {
- return mSourceBlendFactorAlpha;
- }
- //-----------------------------------------------------------------------
- SceneBlendFactor Pass::getDestBlendFactorAlpha(void) const
- {
- return mDestBlendFactorAlpha;
- }
- //-----------------------------------------------------------------------
- bool Pass::hasSeparateSceneBlending() const
- {
- return mSeparateBlend;
- }
- //-----------------------------------------------------------------------
- void Pass::setSceneBlendingOperation(SceneBlendOperation op)
- {
- mBlendOperation = op;
- mSeparateBlendOperation = false;
- }
- //-----------------------------------------------------------------------
- void Pass::setSeparateSceneBlendingOperation(SceneBlendOperation op, SceneBlendOperation alphaOp)
- {
- mBlendOperation = op;
- mAlphaBlendOperation = alphaOp;
- mSeparateBlendOperation = true;
- }
- //-----------------------------------------------------------------------
- SceneBlendOperation Pass::getSceneBlendingOperation() const
- {
- return mBlendOperation;
- }
- //-----------------------------------------------------------------------
- SceneBlendOperation Pass::getSceneBlendingOperationAlpha() const
- {
- return mAlphaBlendOperation;
- }
- //-----------------------------------------------------------------------
- bool Pass::hasSeparateSceneBlendingOperations() const
- {
- return mSeparateBlendOperation;
- }
- //-----------------------------------------------------------------------
- bool Pass::isTransparent(void) const
- {
- // Transparent if any of the destination colour is taken into account
- if (mDestBlendFactor == SBF_ZERO &&
- mSourceBlendFactor != SBF_DEST_COLOUR &&
- mSourceBlendFactor != SBF_ONE_MINUS_DEST_COLOUR &&
- mSourceBlendFactor != SBF_DEST_ALPHA &&
- mSourceBlendFactor != SBF_ONE_MINUS_DEST_ALPHA)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- //-----------------------------------------------------------------------
- void Pass::setDepthCheckEnabled(bool enabled)
- {
- mDepthCheck = enabled;
- }
- //-----------------------------------------------------------------------
- bool Pass::getDepthCheckEnabled(void) const
- {
- return mDepthCheck;
- }
- //-----------------------------------------------------------------------
- void Pass::setDepthWriteEnabled(bool enabled)
- {
- mDepthWrite = enabled;
- }
- //-----------------------------------------------------------------------
- bool Pass::getDepthWriteEnabled(void) const
- {
- return mDepthWrite;
- }
- //-----------------------------------------------------------------------
- void Pass::setDepthFunction( CompareFunction func)
- {
- mDepthFunc = func;
- }
- //-----------------------------------------------------------------------
- CompareFunction Pass::getDepthFunction(void) const
- {
- return mDepthFunc;
- }
- //-----------------------------------------------------------------------
- void Pass::setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage)
- {
- mAlphaRejectFunc = func;
- mAlphaRejectVal = value;
- mAlphaToCoverageEnabled = alphaToCoverage;
- }
- //-----------------------------------------------------------------------
- void Pass::setAlphaRejectFunction(CompareFunction func)
- {
- mAlphaRejectFunc = func;
- }
- //-----------------------------------------------------------------------
- void Pass::setAlphaRejectValue(unsigned char val)
- {
- mAlphaRejectVal = val;
- }
- //---------------------------------------------------------------------
- void Pass::setAlphaToCoverageEnabled(bool enabled)
- {
- mAlphaToCoverageEnabled = enabled;
- }
- //-----------------------------------------------------------------------
- void Pass::setColourWriteEnabled(bool enabled)
- {
- mColourWrite = enabled;
- }
- //-----------------------------------------------------------------------
- bool Pass::getColourWriteEnabled(void) const
- {
- return mColourWrite;
- }
- //-----------------------------------------------------------------------
- void Pass::setCullingMode( CullingMode mode)
- {
- mCullMode = mode;
- }
- //-----------------------------------------------------------------------
- CullingMode Pass::getCullingMode(void) const
- {
- return mCullMode;
- }
- //-----------------------------------------------------------------------
- void Pass::setPolygonMode(PolygonMode mode)
- {
- mPolygonMode = mode;
- }
- //-----------------------------------------------------------------------
- PolygonMode Pass::getPolygonMode(void) const
- {
- return mPolygonMode;
- }
- //-----------------------------------------------------------------------
- void Pass::setDepthBias(float constantBias, float slopeScaleBias)
- {
- mDepthBiasConstant = constantBias;
- mDepthBiasSlopeScale = slopeScaleBias;
- }
- //-----------------------------------------------------------------------
- float Pass::getDepthBiasConstant(void) const
- {
- return mDepthBiasConstant;
- }
- //-----------------------------------------------------------------------
- float Pass::getDepthBiasSlopeScale(void) const
- {
- return mDepthBiasSlopeScale;
- }
- //---------------------------------------------------------------------
- void Pass::setIterationDepthBias(float biasPerIteration)
- {
- mDepthBiasPerIteration = biasPerIteration;
- }
- //---------------------------------------------------------------------
- float Pass::getIterationDepthBias() const
- {
- return mDepthBiasPerIteration;
- }
- //-----------------------------------------------------------------------
- void Pass::setVertexProgram(GpuProgramHandle gpuProgram)
- {
- mVertexProgram = gpuProgram;
- }
- //-----------------------------------------------------------------------
- void Pass::setFragmentProgram(GpuProgramHandle gpuProgram)
- {
- mFragmentProgram = gpuProgram;
- }
- //-----------------------------------------------------------------------
- void Pass::setGeometryProgram(GpuProgramHandle gpuProgram)
- {
- mGeometryProgram = gpuProgram;
- }
- //-----------------------------------------------------------------------
- const GpuProgramHandle& Pass::getVertexProgram(void) const
- {
- return mVertexProgram;
- }
- //-----------------------------------------------------------------------
- const GpuProgramHandle& Pass::getFragmentProgram(void) const
- {
- return mFragmentProgram;
- }
- //-----------------------------------------------------------------------
- const GpuProgramHandle& Pass::getGeometryProgram(void) const
- {
- return mGeometryProgram;
- }
- //----------------------------------------------------------------------
- RTTITypeBase* Pass::getRTTIStatic()
- {
- return PassRTTI::instance();
- }
- //----------------------------------------------------------------------
- RTTITypeBase* Pass::getRTTI() const
- {
- return Pass::getRTTIStatic();
- }
- }
|