BsRenderer.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #pragma once
  5. #include "BsCorePrerequisites.h"
  6. #include "BsGameObject.h"
  7. #include "BsEvent.h"
  8. namespace BansheeEngine
  9. {
  10. /**
  11. * @brief Available parameter block semantics that allow the renderer to identify
  12. * the use of a GPU program parameter block specified in a shader.
  13. */
  14. enum RendererBlockSemantic
  15. {
  16. // 0 - Reserved
  17. RBS_Static = 1,
  18. RBS_PerCamera = 2,
  19. RBS_PerFrame = 3,
  20. RBS_PerObject = 4
  21. };
  22. /**
  23. * @brief Available parameter semantics that allow the renderer to identify
  24. * the use of a GPU parameter specified in a shader.
  25. */
  26. enum RendererParamSemantic
  27. {
  28. // 0 - Reserved
  29. RPS_WorldViewProjTfrm = 1,
  30. RPS_ViewProjTfrm = 2,
  31. RPS_WorldTfrm = 3
  32. };
  33. /**
  34. * @brief Primarily rendering class that allows you to specify how to render objects that exist
  35. * in the scene graph. You need to provide your own implementation of your class.
  36. *
  37. * @note Normally you would iterate over all cameras, find visible objects for each camera and render
  38. * those objects in some way.
  39. */
  40. class BS_CORE_EXPORT Renderer
  41. {
  42. public:
  43. /**
  44. * @brief Called after the renderer has been activated.
  45. *
  46. * @note Internal method.
  47. */
  48. virtual void _onActivated() { }
  49. /**
  50. * @brief Called just before the renderer is deactivated.
  51. *
  52. * @note Internal method.
  53. */
  54. virtual void _onDeactivated() { }
  55. /**
  56. * @brief Name of the renderer. Used by materials to find
  57. * an appropriate technique for this renderer.
  58. */
  59. virtual const String& getName() const = 0;
  60. /**
  61. * @brief Called in order to render all currently active cameras.
  62. */
  63. virtual void renderAll() = 0;
  64. /**
  65. * @brief Allows you to register a callback for the specified viewport. The callback
  66. * will be called before rendering and you will be able to populate the
  67. * render queue with render commands that will be executed when rendering.
  68. */
  69. void addRenderCallback(const Viewport* viewport, std::function<void(const Viewport*, DrawList&)> callback);
  70. protected:
  71. UnorderedMap<const Viewport*, Vector<std::function<void(const Viewport*, DrawList&)>>> mRenderCallbacks;
  72. };
  73. }