1 #pragma once 2 3 #include "Direct3DBase.h" 4 #include <d3d11.h> 5 #include <mutex> 6 7 8 struct ModelViewProjectionConstantBuffer 9 { 10 DirectX::XMFLOAT4X4 model; 11 DirectX::XMFLOAT4X4 view; 12 DirectX::XMFLOAT4X4 projection; 13 }; 14 15 struct Vertex //Overloaded Vertex Structure 16 { VertexVertex17 Vertex(){} VertexVertex18 Vertex(float x, float y, float z, 19 float u, float v) 20 : pos(x,y,z), texCoord(u, v){} 21 22 DirectX::XMFLOAT3 pos; 23 DirectX::XMFLOAT2 texCoord; 24 }; 25 26 // This class renders a simple spinning cube. 27 ref class CubeRenderer sealed : public Direct3DBase 28 { 29 public: 30 CubeRenderer(); 31 32 // Direct3DBase methods. 33 virtual void CreateDeviceResources() override; 34 virtual void CreateWindowSizeDependentResources() override; 35 virtual void Render() override; 36 37 // Method for updating time-dependent objects. 38 void Update(float timeTotal, float timeDelta); 39 40 void CreateTextureFromByte(byte * buffer,int width,int height); 41 private: 42 void Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView); 43 bool m_loadingComplete; 44 45 Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout; 46 Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer; 47 Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer; 48 Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader; 49 Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader; 50 Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer; 51 Microsoft::WRL::ComPtr<ID3D11Texture2D> m_texture; 52 Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_SRV; 53 Microsoft::WRL::ComPtr<ID3D11SamplerState> m_cubesTexSamplerState; 54 uint32 m_indexCount; 55 ModelViewProjectionConstantBuffer m_constantBufferData; 56 std::mutex m_mutex; 57 Microsoft::WRL::ComPtr<ID3D11BlendState> m_transparency; 58 Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_CCWcullMode; 59 Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_CWcullMode; 60 61 }; 62