BsRendererUtility.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. #include "BsRect2.h"
  5. #include "BsVector2I.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Contains various utility methods that make various common operations in the renderer easier.
  10. *
  11. * @note Core thread only.
  12. */
  13. class BS_CORE_EXPORT RendererUtility : public Module<RendererUtility>
  14. {
  15. public:
  16. RendererUtility();
  17. ~RendererUtility();
  18. /**
  19. * @brief Activates the specified material pass for rendering. Any further draw calls will be executed using
  20. * this pass.
  21. *
  22. * @param material Material containing the pass.
  23. * @param passIdx Index of the pass in the material.
  24. *
  25. * @note Core thread.
  26. */
  27. void setPass(const SPtr<MaterialCore>& material, UINT32 passIdx);
  28. /**
  29. * @brief Draws the specified mesh.
  30. *
  31. * @note Core thread.
  32. */
  33. void draw(const SPtr<MeshCoreBase>& mesh, const SubMesh& subMesh);
  34. /**
  35. * @brief Draws a quad over the entire viewport in normalized device coordinates.
  36. *
  37. * @param viewport Destination viewport to draw the quad in.
  38. * @param uv UV coordinates to assign to the corners of the quad.
  39. * @param textureSize Size of the texture the UV coordinates are specified for. If the UV coordinates are already
  40. * in normalized (0, 1) range then keep this value as is. If the UV coordinates are in texels
  41. * then set this value to the texture size so they can be normalized internally.
  42. *
  43. * @note Core thread.
  44. */
  45. void drawScreenQuad(const ViewportCore& viewport, const Rect2& uv = Rect2(0.0f, 0.0f, 1.0f, 1.0f),
  46. const Vector2I& textureSize = Vector2I(1, 1));
  47. private:
  48. SPtr<MeshCore> mFullScreenQuadMesh;
  49. };
  50. /**
  51. * @brief Provides global access to the renderer utility.
  52. *
  53. * @note Core thread only.
  54. */
  55. BS_CORE_EXPORT RendererUtility& gRendererUtility();
  56. }