BsD3D11RenderUtility.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsD3D11Prerequisites.h"
  5. #include "BsModule.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Helper class for DX11 rendering.
  10. */
  11. class D3D11RenderUtility : public Module<D3D11RenderUtility>
  12. {
  13. public:
  14. D3D11RenderUtility(D3D11Device* device);
  15. ~D3D11RenderUtility();
  16. /**
  17. * @brief Draws a quad that clears the current viewport. This is supposed to emulate functionality
  18. * available with other APIs like DX9 and OpenGL where you can clear only a part of the render target.
  19. * (DX11 API only provides a way to clear the entire render target).
  20. *
  21. * @param buffers Combination of one or more elements of FrameBufferType
  22. * denoting which buffers are to be cleared.
  23. * @param color (optional) The color to clear the color buffer with, if enabled.
  24. * @param depth (optional) The value to initialize the depth buffer with, if enabled.
  25. * @param stencil (optional) The value to initialize the stencil buffer with, if enabled.
  26. */
  27. void drawClearQuad(UINT32 clearBuffers, const Color& color, float depth, UINT16 stencil);
  28. protected:
  29. /**
  30. * @brief Initializes resources needed for drawing the clear quad. Should be called one time at start-up.
  31. */
  32. void initClearQuadResources();
  33. D3D11Device* mDevice;
  34. ID3D11Buffer* mClearQuadIB;
  35. ID3D11Buffer* mClearQuadVB;
  36. ID3D11InputLayout* mClearQuadIL;
  37. ID3D11VertexShader* mClearQuadVS;
  38. ID3D11PixelShader* mClearQuadPS;
  39. SPtr<BlendStateCore> mClearQuadBlendStateYesC;
  40. SPtr<BlendStateCore> mClearQuadBlendStateNoC;
  41. SPtr<RasterizerStateCore> mClearQuadRasterizerState;
  42. SPtr<DepthStencilStateCore> mClearQuadDSStateNoD_NoS;
  43. SPtr<DepthStencilStateCore> mClearQuadDSStateYesD_NoS;
  44. SPtr<DepthStencilStateCore> mClearQuadDSStateYesD_YesS;
  45. SPtr<DepthStencilStateCore> mClearQuadDSStateNoD_YesS;
  46. };
  47. }