BsPass.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #include "BsPass.h"
  5. #include "BsRasterizerState.h"
  6. #include "BsBlendState.h"
  7. #include "BsDepthStencilState.h"
  8. #include "BsPassRTTI.h"
  9. #include "BsMaterial.h"
  10. #include "BsGpuParams.h"
  11. #include "BsException.h"
  12. namespace BansheeEngine
  13. {
  14. Pass::Pass()
  15. :mStencilRefValue(0)
  16. { }
  17. Pass::Pass(const Pass& oth)
  18. {
  19. *this = oth;
  20. }
  21. Pass::~Pass()
  22. {
  23. }
  24. Pass& Pass::operator=(const Pass& oth)
  25. {
  26. // Default blending (overwrite)
  27. mBlendState = oth.mBlendState;
  28. mRasterizerState = oth.mRasterizerState;
  29. mDepthStencilState = oth.mDepthStencilState;
  30. mStencilRefValue = oth.mStencilRefValue;
  31. mVertexProgram = oth.mVertexProgram;
  32. mFragmentProgram = oth.mFragmentProgram;
  33. mGeometryProgram = oth.mGeometryProgram;
  34. mHullProgram = oth.mHullProgram;
  35. mDomainProgram = oth.mDomainProgram;
  36. mComputeProgram = oth.mComputeProgram;
  37. return *this;
  38. }
  39. bool Pass::isTransparent() const
  40. {
  41. bool transparent = false;
  42. if(mBlendState != nullptr)
  43. {
  44. for(UINT32 i = 0; i < BS_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. void Pass::setBlendState(HBlendState& blendState)
  60. {
  61. mBlendState = blendState;
  62. }
  63. HBlendState Pass::getBlendState() const
  64. {
  65. return mBlendState;
  66. }
  67. void Pass::setRasterizerState(HRasterizerState& rasterizerState)
  68. {
  69. mRasterizerState = rasterizerState;
  70. }
  71. HRasterizerState Pass::getRasterizerState() const
  72. {
  73. return mRasterizerState;
  74. }
  75. void Pass::setDepthStencilState(HDepthStencilState& depthStencilState)
  76. {
  77. mDepthStencilState = depthStencilState;
  78. }
  79. HDepthStencilState Pass::getDepthStencilState() const
  80. {
  81. return mDepthStencilState;
  82. }
  83. void Pass::setStencilRefValue(UINT32 refValue)
  84. {
  85. mStencilRefValue = refValue;
  86. }
  87. UINT32 Pass::getStencilRefValue() const
  88. {
  89. return mStencilRefValue;
  90. }
  91. RTTITypeBase* Pass::getRTTIStatic()
  92. {
  93. return PassRTTI::instance();
  94. }
  95. RTTITypeBase* Pass::getRTTI() const
  96. {
  97. return Pass::getRTTIStatic();
  98. }
  99. }