diff --git a/GDP/D3D9/Material.cpp b/GDP/D3D9/Material.cpp index 874e044..e1ae343 100644 --- a/GDP/D3D9/Material.cpp +++ b/GDP/D3D9/Material.cpp @@ -1,13 +1,29 @@ #include "Material.h" #include "Utilities.h" +#include "WICTextureLoader9.h" + +using namespace DirectX; + UINT Material::init(IDirect3DDevice9* pD3DDevice, LPCWSTR textureFileName) { + // load texture + HRESULT hr = CreateWICTextureFromFile(pD3DDevice, textureFileName, &_pTexture, 0, 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_BORDERCOLOR, D3DCOLOR_XRGB(255, 0, 255)); + pD3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); + pD3DDevice->SetSamplerState(0, D3DSAMP_MAXMIPLEVEL, 0); } void Material::deInit() diff --git a/GDP/D3D9/Material.h b/GDP/D3D9/Material.h index 7358302..ba6769d 100644 --- a/GDP/D3D9/Material.h +++ b/GDP/D3D9/Material.h @@ -9,6 +9,6 @@ public: void deInit(); private: - IDirect3DTexture9* _texture = {}; + IDirect3DTexture9* _pTexture = {}; }; diff --git a/GDP/D3D9/Mesh.cpp b/GDP/D3D9/Mesh.cpp index 7cbc8c9..f6e91ba 100644 --- a/GDP/D3D9/Mesh.cpp +++ b/GDP/D3D9/Mesh.cpp @@ -31,12 +31,12 @@ void Mesh::update(FLOAT dt) static FLOAT x = 0.0f; static FLOAT y = 0.0f; static FLOAT z = 0.0f; - static FLOAT pitch = XM_PIDIV4; + static FLOAT pitch = 0.0f; static FLOAT yaw = 0.0f; - static FLOAT roll = XM_PIDIV4; + static FLOAT roll = 0.0f; static FLOAT scale = 1.0f; - yaw += 1.0f * dt; + //yaw += 1.0f * dt; FLOAT move = 1.0f * dt; @@ -123,10 +123,10 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice) //// quad with trianglefan //// quad with trianglelist & index buffer - //pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f); - //pVertices[1] = Vertex(0.5f, 0.5f, 0.0f); - //pVertices[2] = Vertex(0.5f, -0.5f, 0.0f); - //pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f); + pVertices[0] = Vertex(-0.5f, 0.5f, 0.0f, 0.0f, 0.0f); + pVertices[1] = Vertex(0.5f, 0.5f, 0.0f, 1.0f, 0.0f); + pVertices[2] = Vertex(0.5f, -0.5f, 0.0f, 1.0f, 1.0f); + pVertices[3] = Vertex(-0.5f, -0.5f, 0.0f, 0.0f, 1.0f); //// cube with color //// front @@ -142,17 +142,17 @@ UINT Mesh::createVertexBuffer(IDirect3DDevice9* pD3DDevice) //pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 200, 200, 200); // cube with uv - // front - pVertices[0] = Vertex(-0.5f, 0.5f, -0.5f, 0.0f, 0.0f); - pVertices[1] = Vertex(0.5f, 0.5f, -0.5f, 1.0f, 0.0f); - pVertices[2] = Vertex(0.5f, -0.5f, -0.5f, 1.0f, 1.0f); - pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f, 0.0f, 1.0f); + //// front + //pVertices[0] = Vertex(-0.5f, 0.5f, -0.5f, 0.0f, 0.0f); + //pVertices[1] = Vertex(0.5f, 0.5f, -0.5f, 1.0f, 0.0f); + //pVertices[2] = Vertex(0.5f, -0.5f, -0.5f, 1.0f, 1.0f); + //pVertices[3] = Vertex(-0.5f, -0.5f, -0.5f, 0.0f, 1.0f); - // back - pVertices[4] = Vertex(0.5f, 0.5f, 0.5f, 0.0f, 0.0f); - pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f, 1.0f, 0.0f); - pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f, 1.0f, 1.0f); - pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 0.0f, 1.0f); + //// back + //pVertices[4] = Vertex(0.5f, 0.5f, 0.5f, 0.0f, 0.0f); + //pVertices[5] = Vertex(-0.5f, 0.5f, 0.5f, 1.0f, 0.0f); + //pVertices[6] = Vertex(-0.5f, -0.5f, 0.5f, 1.0f, 1.0f); + //pVertices[7] = Vertex(0.5f, -0.5f, 0.5f, 0.0f, 1.0f); hr = _pVertexBuffer->Unlock(); CheckFailed(hr, 320);