CubeRenderer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #pragma once
  11. #include "Direct3DBase.h"
  12. struct ModelViewProjectionConstantBuffer
  13. {
  14. DirectX::XMFLOAT4X4 model;
  15. DirectX::XMFLOAT4X4 view;
  16. DirectX::XMFLOAT4X4 projection;
  17. };
  18. struct VertexPositionColor
  19. {
  20. DirectX::XMFLOAT3 pos;
  21. DirectX::XMFLOAT3 color;
  22. };
  23. // This class renders a simple spinning cube.
  24. ref class CubeRenderer sealed : public Direct3DBase
  25. {
  26. public:
  27. CubeRenderer();
  28. // Direct3DBase methods.
  29. virtual void CreateDeviceResources() override;
  30. virtual void CreateWindowSizeDependentResources() override;
  31. virtual void Render() override;
  32. // Method for updating time-dependent objects.
  33. void Update(float timeTotal, float timeDelta);
  34. private:
  35. bool m_loadingComplete;
  36. Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
  37. Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
  38. Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
  39. Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
  40. Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
  41. Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
  42. uint32 m_indexCount;
  43. ModelViewProjectionConstantBuffer m_constantBufferData;
  44. };
粤ICP备19079148号