CmPass.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #include "CmPass.h"
  2. #include "CmRasterizerState.h"
  3. #include "CmBlendState.h"
  4. #include "CmDepthStencilState.h"
  5. #include "CmPassRTTI.h"
  6. #include "CmMaterial.h"
  7. #include "CmGpuParams.h"
  8. #include "CmException.h"
  9. namespace BansheeEngine
  10. {
  11. Pass::Pass()
  12. :mStencilRefValue(0)
  13. { }
  14. Pass::Pass(const Pass& oth)
  15. {
  16. *this = oth;
  17. }
  18. Pass::~Pass()
  19. {
  20. }
  21. Pass& Pass::operator=(const Pass& oth)
  22. {
  23. // Default blending (overwrite)
  24. mBlendState = oth.mBlendState;
  25. mRasterizerState = oth.mRasterizerState;
  26. mDepthStencilState = oth.mDepthStencilState;
  27. mStencilRefValue = oth.mStencilRefValue;
  28. mVertexProgram = oth.mVertexProgram;
  29. mFragmentProgram = oth.mFragmentProgram;
  30. mGeometryProgram = oth.mGeometryProgram;
  31. mHullProgram = oth.mHullProgram;
  32. mDomainProgram = oth.mDomainProgram;
  33. mComputeProgram = oth.mComputeProgram;
  34. return *this;
  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) != BF_ZERO ||
  45. mBlendState->getSrcBlend(i) == BF_DEST_COLOR ||
  46. mBlendState->getSrcBlend(i) == BF_INV_DEST_COLOR ||
  47. mBlendState->getSrcBlend(i) == BF_DEST_ALPHA ||
  48. mBlendState->getSrcBlend(i) == BF_INV_DEST_ALPHA)
  49. {
  50. transparent = true;
  51. }
  52. }
  53. }
  54. return transparent;
  55. }
  56. void Pass::setBlendState(HBlendState& blendState)
  57. {
  58. mBlendState = blendState;
  59. }
  60. HBlendState Pass::getBlendState() const
  61. {
  62. return mBlendState;
  63. }
  64. void Pass::setRasterizerState(HRasterizerState& rasterizerState)
  65. {
  66. mRasterizerState = rasterizerState;
  67. }
  68. HRasterizerState Pass::getRasterizerState() const
  69. {
  70. return mRasterizerState;
  71. }
  72. void Pass::setDepthStencilState(HDepthStencilState& depthStencilState)
  73. {
  74. mDepthStencilState = depthStencilState;
  75. }
  76. HDepthStencilState Pass::getDepthStencilState() const
  77. {
  78. return mDepthStencilState;
  79. }
  80. void Pass::setStencilRefValue(UINT32 refValue)
  81. {
  82. mStencilRefValue = refValue;
  83. }
  84. UINT32 Pass::getStencilRefValue() const
  85. {
  86. return mStencilRefValue;
  87. }
  88. RTTITypeBase* Pass::getRTTIStatic()
  89. {
  90. return PassRTTI::instance();
  91. }
  92. RTTITypeBase* Pass::getRTTI() const
  93. {
  94. return Pass::getRTTIStatic();
  95. }
  96. }