CmPass.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. return *this;
  34. }
  35. //-----------------------------------------------------------------------
  36. bool Pass::isTransparent(void) const
  37. {
  38. bool transparent = false;
  39. if(mBlendState != nullptr)
  40. {
  41. for(UINT32 i = 0; i < CM_MAX_MULTIPLE_RENDER_TARGETS; i++)
  42. {
  43. // Transparent if destination color is taken into account
  44. if (mBlendState->getDstBlend(i) != SBF_ZERO ||
  45. mBlendState->getSrcBlend(i) == SBF_DEST_COLOUR ||
  46. mBlendState->getSrcBlend(i) == SBF_ONE_MINUS_DEST_COLOUR ||
  47. mBlendState->getSrcBlend(i) == SBF_DEST_ALPHA ||
  48. mBlendState->getSrcBlend(i) == SBF_ONE_MINUS_DEST_ALPHA)
  49. {
  50. transparent = true;
  51. }
  52. }
  53. }
  54. return transparent;
  55. }
  56. //----------------------------------------------------------------------
  57. void Pass::setBlendState(BlendStatePtr blendState)
  58. {
  59. mBlendState = blendState;
  60. }
  61. //----------------------------------------------------------------------
  62. BlendStatePtr Pass::getBlendState() const
  63. {
  64. return mBlendState;
  65. }
  66. //----------------------------------------------------------------------
  67. void Pass::setRasterizerState(RasterizerStatePtr rasterizerState)
  68. {
  69. mRasterizerState = rasterizerState;
  70. }
  71. //----------------------------------------------------------------------
  72. RasterizerStatePtr Pass::getRasterizerState() const
  73. {
  74. return mRasterizerState;
  75. }
  76. //-----------------------------------------------------------------------
  77. void Pass::setDepthStencilState(DepthStencilStatePtr depthStencilState)
  78. {
  79. mDepthStencilState = depthStencilState;
  80. }
  81. //-----------------------------------------------------------------------
  82. DepthStencilStatePtr Pass::getDepthStencilState() const
  83. {
  84. return mDepthStencilState;
  85. }
  86. //----------------------------------------------------------------------
  87. void Pass::setStencilRefValue(UINT32 refValue)
  88. {
  89. mStencilRefValue = refValue;
  90. }
  91. //----------------------------------------------------------------------
  92. UINT32 Pass::getStencilRefValue() const
  93. {
  94. return mStencilRefValue;
  95. }
  96. //----------------------------------------------------------------------
  97. RTTITypeBase* Pass::getRTTIStatic()
  98. {
  99. return PassRTTI::instance();
  100. }
  101. //----------------------------------------------------------------------
  102. RTTITypeBase* Pass::getRTTI() const
  103. {
  104. return Pass::getRTTIStatic();
  105. }
  106. }