CmPass.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include "CmPass.h"
  2. #include "CmRasterizerState.h"
  3. #include "CmBlendState.h"
  4. #include "CmDepthStencilState.h"
  5. #include "CmPassRTTI.h"
  6. #include "CmException.h"
  7. namespace CamelotEngine
  8. {
  9. //-----------------------------------------------------------------------------
  10. Pass::Pass()
  11. :mStencilRefValue(0)
  12. { }
  13. //-----------------------------------------------------------------------------
  14. Pass::Pass(const Pass& oth)
  15. {
  16. *this = oth;
  17. }
  18. //-----------------------------------------------------------------------------
  19. Pass::~Pass()
  20. {
  21. }
  22. //-----------------------------------------------------------------------------
  23. Pass& Pass::operator=(const Pass& oth)
  24. {
  25. // Default blending (overwrite)
  26. mBlendState = oth.mBlendState;
  27. mRasterizerState = oth.mRasterizerState;
  28. mDepthStencilState = oth.mDepthStencilState;
  29. mStencilRefValue = oth.mStencilRefValue;
  30. mVertexProgram = oth.mVertexProgram;
  31. mFragmentProgram = oth.mFragmentProgram;
  32. mGeometryProgram = oth.mGeometryProgram;
  33. mHullProgram = oth.mHullProgram;
  34. mDomainProgram = oth.mDomainProgram;
  35. mComputeProgram = oth.mComputeProgram;
  36. return *this;
  37. }
  38. //-----------------------------------------------------------------------
  39. bool Pass::isTransparent(void) const
  40. {
  41. bool transparent = false;
  42. if(mBlendState != nullptr)
  43. {
  44. for(UINT32 i = 0; i < CM_MAX_MULTIPLE_RENDER_TARGETS; i++)
  45. {
  46. // Transparent if destination color is taken into account
  47. if (mBlendState->getDstBlend(i) != BF_ZERO ||
  48. mBlendState->getSrcBlend(i) == BF_DEST_COLOR ||
  49. mBlendState->getSrcBlend(i) == BF_INV_DEST_COLOR ||
  50. mBlendState->getSrcBlend(i) == BF_DEST_ALPHA ||
  51. mBlendState->getSrcBlend(i) == BF_INV_DEST_ALPHA)
  52. {
  53. transparent = true;
  54. }
  55. }
  56. }
  57. return transparent;
  58. }
  59. //----------------------------------------------------------------------
  60. void Pass::setBlendState(BlendStateHandle& blendState)
  61. {
  62. mBlendState = blendState;
  63. }
  64. //----------------------------------------------------------------------
  65. BlendStateHandle Pass::getBlendState() const
  66. {
  67. return mBlendState;
  68. }
  69. //----------------------------------------------------------------------
  70. void Pass::setRasterizerState(RasterizerStateHandle& rasterizerState)
  71. {
  72. mRasterizerState = rasterizerState;
  73. }
  74. //----------------------------------------------------------------------
  75. RasterizerStateHandle Pass::getRasterizerState() const
  76. {
  77. return mRasterizerState;
  78. }
  79. //-----------------------------------------------------------------------
  80. void Pass::setDepthStencilState(DepthStencilStateHandle& depthStencilState)
  81. {
  82. mDepthStencilState = depthStencilState;
  83. }
  84. //-----------------------------------------------------------------------
  85. DepthStencilStateHandle Pass::getDepthStencilState() const
  86. {
  87. return mDepthStencilState;
  88. }
  89. //----------------------------------------------------------------------
  90. void Pass::setStencilRefValue(UINT32 refValue)
  91. {
  92. mStencilRefValue = refValue;
  93. }
  94. //----------------------------------------------------------------------
  95. UINT32 Pass::getStencilRefValue() const
  96. {
  97. return mStencilRefValue;
  98. }
  99. //----------------------------------------------------------------------
  100. RTTITypeBase* Pass::getRTTIStatic()
  101. {
  102. return PassRTTI::instance();
  103. }
  104. //----------------------------------------------------------------------
  105. RTTITypeBase* Pass::getRTTI() const
  106. {
  107. return Pass::getRTTIStatic();
  108. }
  109. }