CmPass.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. { }
  12. //-----------------------------------------------------------------------------
  13. Pass::Pass(const Pass& oth)
  14. {
  15. *this = oth;
  16. }
  17. //-----------------------------------------------------------------------------
  18. Pass::~Pass()
  19. {
  20. }
  21. //-----------------------------------------------------------------------------
  22. Pass& Pass::operator=(const Pass& oth)
  23. {
  24. // Default blending (overwrite)
  25. mBlendState = oth.mBlendState;
  26. mRasterizerState = oth.mRasterizerState;
  27. mDepthStencilState = oth.mDepthStencilState;
  28. mVertexProgram = oth.mVertexProgram;
  29. mFragmentProgram = oth.mFragmentProgram;
  30. mGeometryProgram = oth.mGeometryProgram;
  31. return *this;
  32. }
  33. //-----------------------------------------------------------------------
  34. bool Pass::isTransparent(void) const
  35. {
  36. bool transparent = false;
  37. if(mBlendState != nullptr)
  38. {
  39. for(UINT32 i = 0; i < CM_MAX_MULTIPLE_RENDER_TARGETS; i++)
  40. {
  41. // Transparent if destination color is taken into account
  42. if (mBlendState->getDstBlend(i) != SBF_ZERO ||
  43. mBlendState->getSrcBlend(i) == SBF_DEST_COLOUR ||
  44. mBlendState->getSrcBlend(i) == SBF_ONE_MINUS_DEST_COLOUR ||
  45. mBlendState->getSrcBlend(i) == SBF_DEST_ALPHA ||
  46. mBlendState->getSrcBlend(i) == SBF_ONE_MINUS_DEST_ALPHA)
  47. {
  48. transparent = true;
  49. }
  50. }
  51. }
  52. return transparent;
  53. }
  54. //----------------------------------------------------------------------
  55. void Pass::setBlendState(BlendStatePtr blendState)
  56. {
  57. mBlendState = blendState;
  58. }
  59. //----------------------------------------------------------------------
  60. BlendStatePtr Pass::getBlendState() const
  61. {
  62. return mBlendState;
  63. }
  64. //----------------------------------------------------------------------
  65. void Pass::setRasterizerState(RasterizerStatePtr rasterizerState)
  66. {
  67. mRasterizerState = rasterizerState;
  68. }
  69. //----------------------------------------------------------------------
  70. RasterizerStatePtr Pass::getRasterizerState() const
  71. {
  72. return mRasterizerState;
  73. }
  74. //-----------------------------------------------------------------------
  75. void Pass::setDepthStencilState(DepthStencilStatePtr depthStencilState)
  76. {
  77. mDepthStencilState = depthStencilState;
  78. }
  79. //-----------------------------------------------------------------------
  80. DepthStencilStatePtr Pass::getDepthStencilState() const
  81. {
  82. return mDepthStencilState;
  83. }
  84. //-----------------------------------------------------------------------
  85. void Pass::setVertexProgram(GpuProgramHandle gpuProgram)
  86. {
  87. mVertexProgram = gpuProgram;
  88. }
  89. //-----------------------------------------------------------------------
  90. void Pass::setFragmentProgram(GpuProgramHandle gpuProgram)
  91. {
  92. mFragmentProgram = gpuProgram;
  93. }
  94. //-----------------------------------------------------------------------
  95. void Pass::setGeometryProgram(GpuProgramHandle gpuProgram)
  96. {
  97. mGeometryProgram = gpuProgram;
  98. }
  99. //-----------------------------------------------------------------------
  100. const GpuProgramHandle& Pass::getVertexProgram(void) const
  101. {
  102. return mVertexProgram;
  103. }
  104. //-----------------------------------------------------------------------
  105. const GpuProgramHandle& Pass::getFragmentProgram(void) const
  106. {
  107. return mFragmentProgram;
  108. }
  109. //-----------------------------------------------------------------------
  110. const GpuProgramHandle& Pass::getGeometryProgram(void) const
  111. {
  112. return mGeometryProgram;
  113. }
  114. //----------------------------------------------------------------------
  115. RTTITypeBase* Pass::getRTTIStatic()
  116. {
  117. return PassRTTI::instance();
  118. }
  119. //----------------------------------------------------------------------
  120. RTTITypeBase* Pass::getRTTI() const
  121. {
  122. return Pass::getRTTIStatic();
  123. }
  124. }