CmPass.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmCommonEnums.h"
  4. #include "CmColor.h"
  5. #include "CmIReflectable.h"
  6. namespace CamelotEngine
  7. {
  8. /** Class defining a single pass of a Technique (of a Material), i.e.
  9. a single rendering call.
  10. @remarks
  11. Rendering can be repeated with many passes for more complex effects.
  12. Each pass is a programmable pass (meaning it does
  13. use either a vertex and fragment program, or both).
  14. */
  15. class CM_EXPORT Pass : public IReflectable
  16. {
  17. protected:
  18. BlendStateHandle mBlendState;
  19. RasterizerStateHandle mRasterizerState;
  20. DepthStencilStateHandle mDepthStencilState;
  21. UINT32 mStencilRefValue;
  22. GpuProgramHandle mVertexProgram;
  23. GpuProgramHandle mFragmentProgram;
  24. GpuProgramHandle mGeometryProgram;
  25. GpuProgramHandle mHullProgram;
  26. GpuProgramHandle mDomainProgram;
  27. GpuProgramHandle mComputeProgram;
  28. public:
  29. /// Default constructor
  30. Pass();
  31. /// Copy constructor
  32. Pass(const Pass& oth );
  33. /// Operator = overload
  34. Pass& operator=(const Pass& oth);
  35. virtual ~Pass();
  36. bool hasVertexProgram() const { return mVertexProgram != nullptr; }
  37. bool hasFragmentProgram() const { return mFragmentProgram != nullptr; }
  38. bool hasGeometryProgram() const { return mGeometryProgram != nullptr; }
  39. bool hasHullProgram() const { return mHullProgram != nullptr; }
  40. bool hasDomainProgram() const { return mDomainProgram != nullptr; }
  41. bool hasComputeProgram() const { return mComputeProgram != nullptr; }
  42. /** Returns true if this pass has some element of transparency. */
  43. bool isTransparent(void) const;
  44. /**
  45. * @brief Sets a blend state used for all active render targets.
  46. */
  47. void setBlendState(BlendStateHandle& blendState);
  48. BlendStateHandle getBlendState() const;
  49. void setRasterizerState(RasterizerStateHandle& rasterizerState);
  50. RasterizerStateHandle getRasterizerState() const;
  51. void setDepthStencilState(DepthStencilStateHandle& depthStencilState);
  52. DepthStencilStateHandle getDepthStencilState() const;
  53. void setStencilRefValue(UINT32 refValue);
  54. UINT32 getStencilRefValue() const;
  55. /** Sets the details of the vertex program to use.
  56. */
  57. void setVertexProgram(GpuProgramHandle gpuProgram) { mVertexProgram = gpuProgram; }
  58. /** Gets the vertex program used by this pass. */
  59. const GpuProgramHandle& getVertexProgram(void) const { return mVertexProgram; }
  60. /** Sets the details of the fragment program to use.
  61. */
  62. void setFragmentProgram(GpuProgramHandle gpuProgram) { mFragmentProgram = gpuProgram; }
  63. /** Gets the fragment program used by this pass. */
  64. const GpuProgramHandle& getFragmentProgram(void) const { return mFragmentProgram; }
  65. /** Sets the details of the geometry program to use.
  66. */
  67. void setGeometryProgram(GpuProgramHandle gpuProgram) { mGeometryProgram = gpuProgram; }
  68. /** Gets the geometry program used by this pass. */
  69. const GpuProgramHandle& getGeometryProgram(void) const { return mGeometryProgram; }
  70. /** Sets the details of the hull program to use.
  71. */
  72. void setHullProgram(GpuProgramHandle gpuProgram) { mHullProgram = gpuProgram; }
  73. /** Gets the hull program used by this pass. */
  74. const GpuProgramHandle& getHullProgram(void) const { return mHullProgram; }
  75. /** Sets the details of the domain program to use.
  76. */
  77. void setDomainProgram(GpuProgramHandle gpuProgram) { mDomainProgram = gpuProgram;}
  78. /** Gets the domain program used by this pass. */
  79. const GpuProgramHandle& getDomainProgram(void) const { return mDomainProgram; }
  80. /** Sets the details of the compute program to use.
  81. */
  82. void setComputeProgram(GpuProgramHandle gpuProgram) { mComputeProgram = gpuProgram; }
  83. /** Gets the compute program used by this pass. */
  84. const GpuProgramHandle& getComputeProgram(void) const { return mComputeProgram; }
  85. /************************************************************************/
  86. /* RTTI */
  87. /************************************************************************/
  88. public:
  89. friend class PassRTTI;
  90. static RTTITypeBase* getRTTIStatic();
  91. virtual RTTITypeBase* getRTTI() const;
  92. };
  93. }