Sample3DSceneRenderer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "..\Common\DeviceResources.h"
  3. #include "ShaderStructures.h"
  4. #include "..\Common\StepTimer.h"
  5. namespace TemplateApp
  6. {
  7. // This sample renderer instantiates a basic rendering pipeline.
  8. class Sample3DSceneRenderer
  9. {
  10. public:
  11. Sample3DSceneRenderer(const std::shared_ptr<DX::DeviceResources>& deviceResources);
  12. ~Sample3DSceneRenderer();
  13. void CreateDeviceDependentResources();
  14. void CreateWindowSizeDependentResources();
  15. void Update(DX::StepTimer const& timer);
  16. bool Render();
  17. void SaveState();
  18. void StartTracking();
  19. void TrackingUpdate(float positionX);
  20. void StopTracking();
  21. bool IsTracking() { return m_tracking; }
  22. private:
  23. void LoadState();
  24. void Rotate(float radians);
  25. private:
  26. // Constant buffers must be 256-byte aligned.
  27. static const UINT c_alignedConstantBufferSize = (sizeof(ModelViewProjectionConstantBuffer) + 255) & ~255;
  28. // Cached pointer to device resources.
  29. std::shared_ptr<DX::DeviceResources> m_deviceResources;
  30. // Direct3D resources for cube geometry.
  31. Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList> m_commandList;
  32. Microsoft::WRL::ComPtr<ID3D12RootSignature> m_rootSignature;
  33. Microsoft::WRL::ComPtr<ID3D12PipelineState> m_pipelineState;
  34. Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> m_cbvHeap;
  35. Microsoft::WRL::ComPtr<ID3D12Resource> m_vertexBuffer;
  36. Microsoft::WRL::ComPtr<ID3D12Resource> m_indexBuffer;
  37. Microsoft::WRL::ComPtr<ID3D12Resource> m_constantBuffer;
  38. ModelViewProjectionConstantBuffer m_constantBufferData;
  39. UINT8* m_mappedConstantBuffer;
  40. UINT m_cbvDescriptorSize;
  41. D3D12_RECT m_scissorRect;
  42. std::vector<byte> m_vertexShader;
  43. std::vector<byte> m_pixelShader;
  44. D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView;
  45. D3D12_INDEX_BUFFER_VIEW m_indexBufferView;
  46. // Variables used with the rendering loop.
  47. bool m_loadingComplete;
  48. float m_radiansPerSecond;
  49. float m_angle;
  50. bool m_tracking;
  51. };
  52. }