Files
2025-12-03 15:50:25 +01:00

41 lines
1.2 KiB
C++

#pragma once
#include <d3d11.h>
#include <d3dcompiler.h>
#include <DirectXMath.h>
using namespace DirectX;
#pragma comment(lib, "d3dcompiler.lib")
class Material
{
public:
UINT init(ID3D11Device* pD3DDevice, LPCTSTR 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, LPCTSTR 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 = {};
};