BsCoreRenderer.h 3.3 KB

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