Path: blob/master/samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/CubeRenderer.h
16349 views
#pragma once12#include "Direct3DBase.h"3#include <d3d11.h>4#include <mutex>567struct ModelViewProjectionConstantBuffer8{9DirectX::XMFLOAT4X4 model;10DirectX::XMFLOAT4X4 view;11DirectX::XMFLOAT4X4 projection;12};1314struct Vertex //Overloaded Vertex Structure15{16Vertex(){}17Vertex(float x, float y, float z,18float u, float v)19: pos(x,y,z), texCoord(u, v){}2021DirectX::XMFLOAT3 pos;22DirectX::XMFLOAT2 texCoord;23};2425// This class renders a simple spinning cube.26ref class CubeRenderer sealed : public Direct3DBase27{28public:29CubeRenderer();3031// Direct3DBase methods.32virtual void CreateDeviceResources() override;33virtual void CreateWindowSizeDependentResources() override;34virtual void Render() override;3536// Method for updating time-dependent objects.37void Update(float timeTotal, float timeDelta);3839void CreateTextureFromByte(byte * buffer,int width,int height);40private:41void Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView);42bool m_loadingComplete;4344Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;45Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;46Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;47Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;48Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;49Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;50Microsoft::WRL::ComPtr<ID3D11Texture2D> m_texture;51Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_SRV;52Microsoft::WRL::ComPtr<ID3D11SamplerState> m_cubesTexSamplerState;53uint32 m_indexCount;54ModelViewProjectionConstantBuffer m_constantBufferData;55std::mutex m_mutex;56Microsoft::WRL::ComPtr<ID3D11BlendState> m_transparency;57Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_CCWcullMode;58Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_CWcullMode;5960};616263