BsTechnique.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsIReflectable.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Technique represents a specific implementation of a shader. Contains
  8. * a number of passes that will be executed when rendering objects using this technique.
  9. *
  10. * @note Normally you want to have a separate technique for every render system and renderer your
  11. * application supports. For example, if you are supporting DirectX11 and OpenGL you will
  12. * want to have two techniques, one using HLSL based GPU programs, other using GLSL. Those
  13. * techniques should try to mirror each others end results.
  14. */
  15. class BS_CORE_EXPORT Technique : public IReflectable
  16. {
  17. public:
  18. Technique(const String& renderSystem, const String& renderer);
  19. /**
  20. * @brief Registers a new pass with the technique. It's up to the caller
  21. * to register GPU programs in the returned pass.
  22. *
  23. * @note Passes added first will be executed first when rendering.
  24. */
  25. PassPtr addPass();
  26. /**
  27. * @brief Removes a pass with the specified index.
  28. */
  29. void removePass(UINT32 idx);
  30. /**
  31. * @brief Returns a pass with the specified index.
  32. */
  33. PassPtr getPass(UINT32 idx) const;
  34. /**
  35. * @brief Returns total number of passes.
  36. */
  37. UINT32 getNumPasses() const { return (UINT32)mPasses.size(); }
  38. /**
  39. * @brief Checks if this technique is supported based on current
  40. * render and other systems.
  41. */
  42. bool isSupported() const;
  43. private:
  44. String mRenderSystem;
  45. String mRenderer;
  46. Vector<PassPtr> mPasses;
  47. /************************************************************************/
  48. /* RTTI */
  49. /************************************************************************/
  50. /**
  51. * @brief Serialization only constructor.
  52. */
  53. Technique() {}
  54. public:
  55. friend class TechniqueRTTI;
  56. static RTTITypeBase* getRTTIStatic();
  57. virtual RTTITypeBase* getRTTI() const;
  58. };
  59. }