BsRendererUtility.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 Sets parameters (textures, samplers, buffers) for the currently active pass.
  30. *
  31. * @param material Material whose pass' parameters to bind.
  32. * @param passIdx Index of the pass in the material.
  33. *
  34. * @note Core thread.
  35. */
  36. static void setPassParams(const SPtr<MaterialCore>& material, UINT32 passIdx = 0);
  37. /**
  38. * @brief Draws the specified mesh.
  39. *
  40. * @note Core thread.
  41. */
  42. void draw(const SPtr<MeshCoreBase>& mesh, const SubMesh& subMesh);
  43. /**
  44. * @brief Draws a quad over the entire viewport in normalized device coordinates.
  45. *
  46. * @param viewport Destination viewport to draw the quad in.
  47. * @param uv UV coordinates to assign to the corners of the quad.
  48. * @param textureSize Size of the texture the UV coordinates are specified for. If the UV coordinates are already
  49. * in normalized (0, 1) range then keep this value as is. If the UV coordinates are in texels
  50. * then set this value to the texture size so they can be normalized internally.
  51. *
  52. * @note Core thread.
  53. */
  54. void drawScreenQuad(const ViewportCore& viewport, const Rect2& uv = Rect2(0.0f, 0.0f, 1.0f, 1.0f),
  55. const Vector2I& textureSize = Vector2I(1, 1));
  56. private:
  57. SPtr<MeshCore> mFullScreenQuadMesh;
  58. };
  59. /**
  60. * @brief Provides easy access to RendererUtility.
  61. *
  62. * @note Core thread only.
  63. */
  64. BS_CORE_EXPORT RendererUtility& gRendererUtility();
  65. }