BsRenderer.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsGameObject.h"
  4. #include "BsEvent.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Available parameter block semantics that allow the renderer to identify
  9. * the use of a GPU program parameter block specified in a shader.
  10. */
  11. enum RendererBlockSemantic
  12. {
  13. // 0 - Reserved
  14. RBS_Static = 1,
  15. RBS_PerCamera = 2,
  16. RBS_PerFrame = 3,
  17. RBS_PerObject = 4
  18. };
  19. /**
  20. * @brief Available parameter semantics that allow the renderer to identify
  21. * the use of a GPU parameter specified in a shader.
  22. */
  23. enum RendererParamSemantic
  24. {
  25. // 0 - Reserved
  26. RPS_WorldViewProjTfrm = 1,
  27. RPS_ViewProjTfrm = 2,
  28. RPS_WorldTfrm = 3,
  29. RPS_MainTex = 4
  30. };
  31. /**
  32. * @brief Primarily rendering class that allows you to specify how to render objects that exist
  33. * in the scene graph. You need to provide your own implementation of your class.
  34. *
  35. * @note Normally you would iterate over all cameras, find visible objects for each camera and render
  36. * those objects in some way.
  37. */
  38. class BS_CORE_EXPORT Renderer
  39. {
  40. public:
  41. /**
  42. * @brief Called after the renderer has been activated.
  43. *
  44. * @note Internal method.
  45. */
  46. virtual void _onActivated() { }
  47. /**
  48. * @brief Called just before the renderer is deactivated.
  49. *
  50. * @note Internal method.
  51. */
  52. virtual void _onDeactivated() { }
  53. /**
  54. * @brief Name of the renderer. Used by materials to find
  55. * an appropriate technique for this renderer.
  56. */
  57. virtual const String& getName() const = 0;
  58. /**
  59. * @brief Called in order to render all currently active cameras.
  60. */
  61. virtual void renderAll() = 0;
  62. /**
  63. * @brief Activates the specified pass on the pipeline.
  64. *
  65. * @param material Parent material of the pass.
  66. * @param passIdx Index of the pass in the parent material.
  67. *
  68. * @note Core thread only.
  69. */
  70. static void setPass(const MaterialProxy& material, UINT32 passIdx);
  71. /**
  72. * @brief Draws the specified mesh proxy with last set pass.
  73. *
  74. * @note Core thread only.
  75. */
  76. static void draw(const MeshProxy& mesh);
  77. /**
  78. * @brief Callback that gets triggered before a viewport gets rendered.
  79. *
  80. * @note Sim thread only
  81. */
  82. Event<void(const Viewport*, DrawList&)> onRenderViewport;
  83. /**
  84. * @brief Callback that gets triggered before main render queue items are rendered
  85. * to the provided viewport, called from the core thread directly.
  86. *
  87. * @note Core thread only.
  88. */
  89. Event<void(const CameraProxy&)> onCorePreRenderViewport;
  90. /**
  91. * @brief Callback that gets triggered after main render queue items are rendered,
  92. * to the provided viewport, called from the core thread directly.
  93. *
  94. * @note Core thread only.
  95. */
  96. Event<void(const CameraProxy&)> onCorePostRenderViewport;
  97. };
  98. }