#pragma once #include #include #include using namespace DirectX; #pragma comment(lib, "d3dcompiler.lib") class Material { public: UINT init(ID3D11Device* pD3DDevice, LPCWSTR textureFileName); void render(ID3D11DeviceContext* pD3DDeviceContext); void deInit(); void setMatrixBuffer(ID3D11DeviceContext* pD3DDeviceContext, const XMFLOAT4X4& worldMatrix, const XMFLOAT4X4& viewMatrix, const XMFLOAT4X4& projectionMatrix); private: UINT createVertexShader(ID3D11Device* pD3DDevice); UINT createPixelShader(ID3D11Device* pD3DDevice); UINT createInputLayout(ID3D11Device* pD3DDevice, ID3DBlob* pCompiledVertexShaderCode); UINT createMatrixBuffer(ID3D11Device* pD3DDevice); UINT createTextureAndSamplerState(ID3D11Device* pD3DDevice, LPCWSTR textureFileName); ID3D11VertexShader* _pVertexShader = nullptr; ID3D11PixelShader* _pPixelShader = nullptr; ID3D11InputLayout* _pInputLayout = nullptr; // byte structure of vertex struct MatrixBuffer { XMFLOAT4X4 WorldViewProjectionMatrix; XMFLOAT4X4 WorldMatrix; }; ID3D11Buffer* _pMatrixBuffer = nullptr; ID3D11ShaderResourceView* _pTexture = {}; ID3D11SamplerState* _pSamplerState = {}; };