BsRenderer.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 Called whenever a new camera is created.
  64. *
  65. * @note Core thread.
  66. * Internal method.
  67. */
  68. virtual void _notifyCameraAdded(const CameraHandlerCore* camera) { }
  69. /**
  70. * @brief Called whenever a camera is destroyed.
  71. *
  72. * @note Core thread.
  73. * Internal method.
  74. */
  75. virtual void _notifyCameraRemoved(const CameraHandlerCore* camera) { }
  76. /**
  77. * @brief Activates the specified pass on the pipeline.
  78. *
  79. * @param material Parent material of the pass.
  80. * @param passIdx Index of the pass in the parent material.
  81. *
  82. * @note Core thread only.
  83. */
  84. static void setPass(const MaterialProxy& material, UINT32 passIdx);
  85. /**
  86. * @brief Draws the specified mesh proxy with last set pass.
  87. *
  88. * @note Core thread only.
  89. */
  90. static void draw(const SPtr<MeshCoreBase>& mesh, const SubMesh& subMesh);
  91. /**
  92. * @brief Callback that gets triggered before a viewport gets rendered.
  93. *
  94. * @note Sim thread only
  95. */
  96. Event<void(const Viewport*, DrawList&)> onRenderViewport;
  97. /**
  98. * @brief Callback that gets triggered before main render queue items are rendered
  99. * to the provided viewport, called from the core thread directly.
  100. *
  101. * @note Core thread only.
  102. */
  103. Event<void(const CameraHandlerCore&)> onCorePreRenderViewport;
  104. /**
  105. * @brief Callback that gets triggered after main render queue items are rendered,
  106. * to the provided viewport, called from the core thread directly.
  107. *
  108. * @note Core thread only.
  109. */
  110. Event<void(const CameraHandlerCore&)> onCorePostRenderViewport;
  111. };
  112. }