QuadRenderer.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include "Direct3DBase.h"
  3. #include <d3d11.h>
  4. struct ModelViewProjectionConstantBuffer
  5. {
  6. DirectX::XMFLOAT4X4 model;
  7. DirectX::XMFLOAT4X4 view;
  8. DirectX::XMFLOAT4X4 projection;
  9. };
  10. struct Vertex //Overloaded Vertex Structure
  11. {
  12. Vertex(){}
  13. Vertex(float x, float y, float z,
  14. float u, float v)
  15. : pos(x,y,z), texCoord(u, v){}
  16. DirectX::XMFLOAT3 pos;
  17. DirectX::XMFLOAT2 texCoord;
  18. };
  19. // This class renders a simple quad.
  20. ref class QuadRenderer sealed : public Direct3DBase
  21. {
  22. public:
  23. QuadRenderer();
  24. void Update(float timeTotal = 0.0f, float timeDelta = 0.0f);
  25. void CreateTextureFromByte(byte * buffer,int width,int height);
  26. // Direct3DBase methods.
  27. virtual void CreateDeviceResources() override;
  28. virtual void CreateWindowSizeDependentResources() override;
  29. virtual void Render() override;
  30. private:
  31. void Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView);
  32. bool m_loadingComplete;
  33. uint32 m_indexCount;
  34. ModelViewProjectionConstantBuffer m_constantBufferData;
  35. Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
  36. Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
  37. Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
  38. Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
  39. Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
  40. Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
  41. Microsoft::WRL::ComPtr<ID3D11Texture2D> m_Texture;
  42. Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_SRV;
  43. Microsoft::WRL::ComPtr<ID3D11SamplerState> m_QuadsTexSamplerState;
  44. Microsoft::WRL::ComPtr<ID3D11BlendState> m_Transparency;
  45. Microsoft::WRL::ComPtr<ID3D11RasterizerState> CCWcullMode;
  46. Microsoft::WRL::ComPtr<ID3D11RasterizerState> CWcullMode;
  47. };