BsRendererUtility.h 2.3 KB

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