BsD3D11RenderUtility.h 1.8 KB

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