Start converting D3D9 to D3D11
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#include "Material.h"
|
||||
#include "Utilities.h"
|
||||
#include "WICTextureLoader9.h"
|
||||
|
||||
UINT Material::init(IDirect3DDevice9* pD3DDevice, LPCTSTR textureFileName)
|
||||
{
|
||||
HRESULT hr = DirectX::CreateWICTextureFromFile(pD3DDevice, textureFileName, &_pTexture, 0, DirectX::WIC_LOADER_MIP_AUTOGEN);
|
||||
CheckFailed(hr, 600);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Material::render(IDirect3DDevice9* pD3DDevice)
|
||||
{
|
||||
// set texture
|
||||
pD3DDevice->SetTexture(0, _pTexture);
|
||||
|
||||
// set sampler state
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, D3DCOLOR_XRGB(200, 0, 200));
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MAXMIPLEVEL, 0);
|
||||
|
||||
// set material
|
||||
D3DMATERIAL9 material = {};
|
||||
material.Diffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
material.Specular = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
material.Power = 100.0f;
|
||||
material.Ambient = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
material.Emissive = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
pD3DDevice->SetMaterial(&material);
|
||||
}
|
||||
|
||||
void Material::deInit()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user