BsCoreRenderer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 CoreRenderer
  39. {
  40. public:
  41. virtual ~CoreRenderer() { }
  42. /**
  43. * @brief Called after the renderer has been activated.
  44. *
  45. * @note Internal method.
  46. */
  47. virtual void _onActivated() { }
  48. /**
  49. * @brief Called just before the renderer is deactivated.
  50. *
  51. * @note Internal method.
  52. */
  53. virtual void _onDeactivated() { }
  54. /**
  55. * @brief Name of the renderer. Used by materials to find
  56. * an appropriate technique for this renderer.
  57. */
  58. virtual const String& getName() const = 0;
  59. /**
  60. * @brief Called in order to render all currently active cameras.
  61. */
  62. virtual void renderAll() = 0;
  63. /**
  64. * @brief Called whenever a new camera is created.
  65. *
  66. * @note Core thread.
  67. * Internal method.
  68. */
  69. virtual void _notifyCameraAdded(const CameraHandlerCore* camera) { }
  70. /**
  71. * @brief Called whenever a camera is destroyed.
  72. *
  73. * @note Core thread.
  74. * Internal method.
  75. */
  76. virtual void _notifyCameraRemoved(const CameraHandlerCore* camera) { }
  77. /**
  78. * @brief Activates the specified pass on the pipeline.
  79. *
  80. * @param material Parent material of the pass.
  81. * @param passIdx Index of the pass in the parent material.
  82. *
  83. * @note Core thread only.
  84. */
  85. static void setPass(const SPtr<MaterialCore>& material, UINT32 passIdx);
  86. /**
  87. * @brief Draws the specified mesh proxy with last set pass.
  88. *
  89. * @note Core thread only.
  90. */
  91. static void draw(const SPtr<MeshCoreBase>& mesh, const SubMesh& subMesh);
  92. /**
  93. * @brief Callback that gets triggered before a viewport gets rendered.
  94. *
  95. * @note Sim thread only
  96. */
  97. Event<void(const Viewport*, DrawList&)> onRenderViewport;
  98. /**
  99. * @brief Callback that gets triggered before main render queue items are rendered
  100. * to the provided viewport, called from the core thread directly.
  101. *
  102. * @note Core thread only.
  103. */
  104. Event<void(const CameraHandlerCore&)> onCorePreRenderViewport;
  105. /**
  106. * @brief Callback that gets triggered after main render queue items are rendered,
  107. * to the provided viewport, called from the core thread directly.
  108. *
  109. * @note Core thread only.
  110. */
  111. Event<void(const CameraHandlerCore&)> onCorePostRenderViewport;
  112. };
  113. }