| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- #include "CmPass.h"
- #include "CmPassRTTI.h"
- #include "CmException.h"
- #include "CmBlendState.h"
- namespace CamelotEngine
- {
- //-----------------------------------------------------------------------------
- Pass::Pass()
- : mDepthCheck(true)
- , mDepthWrite(true)
- , mDepthFunc(CMPF_LESS_EQUAL)
- , mDepthBiasConstant(0.0f)
- , mDepthBiasSlopeScale(0.0f)
- , mDepthBiasPerIteration(0.0f)
- , mCullMode(CULL_CLOCKWISE)
- , mPolygonMode(PM_SOLID)
- {
- }
- //-----------------------------------------------------------------------------
- Pass::Pass(const Pass& oth)
- {
- *this = oth;
- }
- //-----------------------------------------------------------------------------
- Pass::~Pass()
- {
-
- }
- //-----------------------------------------------------------------------------
- Pass& Pass::operator=(const Pass& oth)
- {
- // Default blending (overwrite)
- mBlendState = oth.mBlendState;
- mDepthCheck = oth.mDepthCheck;
- mDepthWrite = oth.mDepthWrite;
- mDepthFunc = oth.mDepthFunc;
- mDepthBiasConstant = oth.mDepthBiasConstant;
- mDepthBiasSlopeScale = oth.mDepthBiasSlopeScale;
- mDepthBiasPerIteration = oth.mDepthBiasPerIteration;
- mCullMode = oth.mCullMode;
- mPolygonMode = oth.mPolygonMode;
- mVertexProgram = oth.mVertexProgram;
- mFragmentProgram = oth.mFragmentProgram;
- mGeometryProgram = oth.mGeometryProgram;
- return *this;
- }
- //-----------------------------------------------------------------------
- bool Pass::isTransparent(void) const
- {
- bool transparent = false;
- if(mBlendState != nullptr)
- {
- for(UINT32 i = 0; i < CM_MAX_MULTIPLE_RENDER_TARGETS; i++)
- {
- // Transparent if destination color is taken into account
- if (mBlendState->getDstBlend(i) != SBF_ZERO ||
- mBlendState->getSrcBlend(i) == SBF_DEST_COLOUR ||
- mBlendState->getSrcBlend(i) == SBF_ONE_MINUS_DEST_COLOUR ||
- mBlendState->getSrcBlend(i) == SBF_DEST_ALPHA ||
- mBlendState->getSrcBlend(i) == SBF_ONE_MINUS_DEST_ALPHA)
- {
- transparent = true;
- }
- }
- }
- return transparent;
- }
- //----------------------------------------------------------------------
- void Pass::setBlendState(BlendStatePtr blendState)
- {
- mBlendState = blendState;
- }
- //----------------------------------------------------------------------
- BlendStatePtr Pass::getBlendState() const
- {
- return mBlendState;
- }
- //-----------------------------------------------------------------------
- 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::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();
- }
- }
|