BsD3D11RenderUtility.h 2.0 KB

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