Add input layout
Add matrix buffer Convert camera to D3D11
This commit is contained in:
+3
-12
@@ -1,10 +1,6 @@
|
|||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
#include <DirectXMath.h>
|
UINT Camera::init(UINT width, UINT height)
|
||||||
|
|
||||||
using namespace DirectX;
|
|
||||||
|
|
||||||
UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
|
|
||||||
{
|
{
|
||||||
// view matrix
|
// view matrix
|
||||||
XMVECTOR position = XMVectorSet(0.0f, 0.0f, -1.0f, 0.0f);
|
XMVECTOR position = XMVectorSet(0.0f, 0.0f, -1.0f, 0.0f);
|
||||||
@@ -12,9 +8,7 @@ UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
|
|||||||
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
|
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
XMMATRIX lookTo = XMMatrixLookToLH(position, forward, up);
|
XMMATRIX lookTo = XMMatrixLookToLH(position, forward, up);
|
||||||
XMFLOAT4X4 v;
|
XMStoreFloat4x4(&_viewMatrix, lookTo);
|
||||||
XMStoreFloat4x4(&v, lookTo);
|
|
||||||
_viewMatrix = *reinterpret_cast<D3DMATRIX*>(&v);
|
|
||||||
|
|
||||||
// projection matrix
|
// projection matrix
|
||||||
float fov = XMConvertToRadians(60.0f);
|
float fov = XMConvertToRadians(60.0f);
|
||||||
@@ -23,10 +17,7 @@ UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
|
|||||||
float farClippingPlane = 100.0f;
|
float farClippingPlane = 100.0f;
|
||||||
|
|
||||||
XMMATRIX perspective = XMMatrixPerspectiveFovLH(fov, aspectRatio, nearClippingPlane, farClippingPlane);
|
XMMATRIX perspective = XMMatrixPerspectiveFovLH(fov, aspectRatio, nearClippingPlane, farClippingPlane);
|
||||||
XMStoreFloat4x4(reinterpret_cast<XMFLOAT4X4*>(&_projectionMatrix), perspective);
|
XMStoreFloat4x4(&_projectionMatrix, perspective);
|
||||||
|
|
||||||
pD3DDevice->SetTransform(D3DTS_VIEW, &_viewMatrix);
|
|
||||||
pD3DDevice->SetTransform(D3DTS_PROJECTION, &_projectionMatrix);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -1,15 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <d3d9.h>
|
#include <DirectXMath.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
using namespace DirectX;
|
||||||
|
|
||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UINT init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height);
|
UINT init(UINT width, UINT height);
|
||||||
void update(FLOAT dt);
|
void update(FLOAT dt);
|
||||||
void deInit();
|
void deInit();
|
||||||
|
|
||||||
|
const XMFLOAT4X4& getViewMatrix() const { return _viewMatrix; }
|
||||||
|
const XMFLOAT4X4& getProjectionMatrix() const { return _projectionMatrix; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
D3DMATRIX _viewMatrix = {};
|
XMFLOAT4X4 _viewMatrix = {};
|
||||||
D3DMATRIX _projectionMatrix = {};
|
XMFLOAT4X4 _projectionMatrix = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+113
-20
@@ -5,39 +5,86 @@
|
|||||||
|
|
||||||
UINT Material::init(ID3D11Device* pD3DDevice, LPCTSTR textureFileName)
|
UINT Material::init(ID3D11Device* pD3DDevice, LPCTSTR textureFileName)
|
||||||
{
|
{
|
||||||
HRESULT hr = DirectX::CreateWICTextureFromFile(pD3DDevice, textureFileName, &_pTexture, 0, DirectX::WIC_LOADER_MIP_AUTOGEN);
|
//HRESULT hr = DirectX::CreateWICTextureFromFile(pD3DDevice, textureFileName, &_pTexture, 0, DirectX::WIC_LOADER_MIP_AUTOGEN);
|
||||||
CheckFailed(hr, 600);
|
//CheckFailed(hr, 600);
|
||||||
|
|
||||||
|
UINT error = 0;
|
||||||
|
|
||||||
|
error = createVertexShader(pD3DDevice);
|
||||||
|
CheckError(error);
|
||||||
|
|
||||||
|
error = createPixelShader(pD3DDevice);
|
||||||
|
CheckError(error);
|
||||||
|
|
||||||
|
error = createMatrixBuffer(pD3DDevice);
|
||||||
|
CheckError(error);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Material::render(ID3D11DeviceContext* pD3DDeviceContext)
|
void Material::render(ID3D11DeviceContext* pD3DDeviceContext)
|
||||||
{
|
{
|
||||||
// set texture
|
//// set texture
|
||||||
pD3DDevice->SetTexture(0, _pTexture);
|
//pD3DDevice->SetTexture(0, _pTexture);
|
||||||
|
|
||||||
// set sampler state
|
//// set sampler state
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, D3DCOLOR_XRGB(100, 0, 100));
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, D3DCOLOR_XRGB(100, 0, 100));
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
|
||||||
pD3DDevice->SetSamplerState(0, D3DSAMP_MAXMIPLEVEL, 0);
|
//pD3DDevice->SetSamplerState(0, D3DSAMP_MAXMIPLEVEL, 0);
|
||||||
|
|
||||||
// set material
|
//// set material
|
||||||
D3DMATERIAL9 material = {};
|
//D3DMATERIAL9 material = {};
|
||||||
material.Ambient = { 1.0f, 1.0f, 1.0f, 1.0f };
|
//material.Ambient = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
material.Diffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
|
//material.Diffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
material.Specular = { 1.0f, 1.0f, 1.0f, 1.0f };
|
//material.Specular = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
material.Power = 100.0f;
|
//material.Power = 100.0f;
|
||||||
material.Emissive = { 1.0f, 0.0f, 0.0f, 1.0f };
|
//material.Emissive = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
|
||||||
pD3DDevice->SetMaterial(&material);
|
//pD3DDevice->SetMaterial(&material);
|
||||||
|
|
||||||
|
// set shader
|
||||||
|
pD3DDeviceContext->VSSetShader(_pVertexShader, nullptr, 0);
|
||||||
|
pD3DDeviceContext->PSSetShader(_pPixelShader, nullptr, 0);
|
||||||
|
|
||||||
|
// set input layout
|
||||||
|
pD3DDeviceContext->IASetInputLayout(_pInputLayout);
|
||||||
|
|
||||||
|
// set matrix buffer
|
||||||
|
pD3DDeviceContext->VSSetConstantBuffers(0, 1, &_pMatrixBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Material::deInit()
|
void Material::deInit()
|
||||||
{
|
{
|
||||||
|
safeRelease(_pInputLayout);
|
||||||
|
safeRelease(_pPixelShader);
|
||||||
|
safeRelease(_pVertexShader);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT Material::setMatrices(ID3D11DeviceContext* pD3DDeviceContext,
|
||||||
|
const XMFLOAT4X4& worldMatrix, const XMFLOAT4X4& viewMatrix, const XMFLOAT4X4& projectionMatrix)
|
||||||
|
{
|
||||||
|
// 1. load matrix data
|
||||||
|
XMMATRIX w = XMLoadFloat4x4(&worldMatrix);
|
||||||
|
XMMATRIX v = XMLoadFloat4x4(&viewMatrix);
|
||||||
|
XMMATRIX p = XMLoadFloat4x4(&projectionMatrix);
|
||||||
|
|
||||||
|
// 2. map matrix buffer
|
||||||
|
D3D11_MAPPED_SUBRESOURCE data = {};
|
||||||
|
HRESULT hr = pD3DDeviceContext->Map(_pMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &data);
|
||||||
|
CheckFailed(hr, 665);
|
||||||
|
|
||||||
|
// 3. set data
|
||||||
|
MatrixBuffer* pMatrixBuffer = static_cast<MatrixBuffer*>(data.pData);
|
||||||
|
XMStoreFloat4x4(&pMatrixBuffer->WorldViewProjectionMatrix, XMMatrixTranspose(w * v * p));
|
||||||
|
|
||||||
|
// 4. unmap matrix buffer
|
||||||
|
pD3DDeviceContext->Unmap(_pMatrixBuffer, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT Material::createVertexShader(ID3D11Device* pD3DDevice)
|
UINT Material::createVertexShader(ID3D11Device* pD3DDevice)
|
||||||
@@ -69,6 +116,9 @@ UINT Material::createVertexShader(ID3D11Device* pD3DDevice)
|
|||||||
);
|
);
|
||||||
CheckFailed(hr, 605);
|
CheckFailed(hr, 605);
|
||||||
|
|
||||||
|
UINT error = createInputLayout(pD3DDevice, pCompiledShaderCode);
|
||||||
|
CheckError(error);
|
||||||
|
|
||||||
safeRelease(pCompiledShaderCode);
|
safeRelease(pCompiledShaderCode);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -94,5 +144,48 @@ UINT Material::createPixelShader(ID3D11Device* pD3DDevice)
|
|||||||
|
|
||||||
UINT Material::createInputLayout(ID3D11Device* pD3DDevice, ID3DBlob* pCompiledVertexShader)
|
UINT Material::createInputLayout(ID3D11Device* pD3DDevice, ID3DBlob* pCompiledVertexShader)
|
||||||
{
|
{
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics
|
||||||
|
D3D11_INPUT_ELEMENT_DESC inputs[4] = {};
|
||||||
|
|
||||||
|
// position
|
||||||
|
inputs[0].SemanticName = "POSITION";
|
||||||
|
inputs[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||||
|
|
||||||
|
// normal
|
||||||
|
inputs[1].SemanticName = "NORMAL";
|
||||||
|
inputs[1].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||||
|
inputs[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||||
|
|
||||||
|
// uv
|
||||||
|
inputs[2].SemanticName = "TEXCOORD";
|
||||||
|
inputs[2].Format = DXGI_FORMAT_R32G32_FLOAT;
|
||||||
|
inputs[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||||
|
|
||||||
|
// color
|
||||||
|
inputs[3].SemanticName = "COLOR";
|
||||||
|
inputs[3].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||||
|
inputs[3].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||||
|
|
||||||
|
HRESULT hr = pD3DDevice->CreateInputLayout(
|
||||||
|
inputs, std::size(inputs), // array of element descriptions & size of array
|
||||||
|
pCompiledVertexShader->GetBufferPointer(), pCompiledVertexShader->GetBufferSize(), // check vertex compatability with vertex shader
|
||||||
|
&_pInputLayout
|
||||||
|
);
|
||||||
|
CheckFailed(hr, 640);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT Material::createMatrixBuffer(ID3D11Device* pD3DDevice)
|
||||||
|
{
|
||||||
|
D3D11_BUFFER_DESC desc = {};
|
||||||
|
desc.ByteWidth = sizeof(MatrixBuffer);
|
||||||
|
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // has to be set if D3D11_USAGE_DYNAMIC or D3D11_USAGE_STAGING is used
|
||||||
|
|
||||||
|
HRESULT hr = pD3DDevice->CreateBuffer(&desc, nullptr, &_pMatrixBuffer);
|
||||||
|
CheckFailed(hr, 660);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
#pragma comment(lib, "d3dcompiler.lib")
|
#pragma comment(lib, "d3dcompiler.lib")
|
||||||
|
|
||||||
|
using namespace DirectX;
|
||||||
|
|
||||||
class Material
|
class Material
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -11,15 +14,26 @@ public:
|
|||||||
void render(ID3D11DeviceContext* pD3DDeviceContext);
|
void render(ID3D11DeviceContext* pD3DDeviceContext);
|
||||||
void deInit();
|
void deInit();
|
||||||
|
|
||||||
|
UINT setMatrices(ID3D11DeviceContext* pD3DDeviceContext,
|
||||||
|
const XMFLOAT4X4& worldMatrix, const XMFLOAT4X4& viewMatrix, const XMFLOAT4X4& projectionMatrix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT createVertexShader(ID3D11Device* pD3DDevice);
|
UINT createVertexShader(ID3D11Device* pD3DDevice);
|
||||||
UINT createPixelShader(ID3D11Device* pD3DDevice);
|
UINT createPixelShader(ID3D11Device* pD3DDevice);
|
||||||
UINT createInputLayout(ID3D11Device* pD3DDevice, ID3DBlob* pCompiledVertexShader);
|
UINT createInputLayout(ID3D11Device* pD3DDevice, ID3DBlob* pCompiledVertexShader);
|
||||||
|
|
||||||
|
UINT createMatrixBuffer(ID3D11Device* pD3DDevice);
|
||||||
|
|
||||||
ID3D11VertexShader* _pVertexShader = nullptr;
|
ID3D11VertexShader* _pVertexShader = nullptr;
|
||||||
ID3D11PixelShader* _pPixelShader = nullptr;
|
ID3D11PixelShader* _pPixelShader = nullptr;
|
||||||
ID3D11InputLayout* _pInputLayout = nullptr;
|
ID3D11InputLayout* _pInputLayout = nullptr;
|
||||||
|
|
||||||
//IDirect3DTexture9* _pTexture = nullptr;
|
//IDirect3DTexture9* _pTexture = nullptr;
|
||||||
|
|
||||||
|
struct MatrixBuffer
|
||||||
|
{
|
||||||
|
XMFLOAT4X4 WorldViewProjectionMatrix;
|
||||||
|
};
|
||||||
|
ID3D11Buffer* _pMatrixBuffer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ void Mesh::render(ID3D11DeviceContext* pD3DDeviceContext)
|
|||||||
);
|
);
|
||||||
|
|
||||||
pD3DDeviceContext->IASetIndexBuffer(_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
|
pD3DDeviceContext->IASetIndexBuffer(_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
|
||||||
pD3DDeviceContext->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
pD3DDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
// draw call
|
// draw call
|
||||||
pD3DDeviceContext->DrawIndexed(_indexCount, 0, 0);
|
pD3DDeviceContext->DrawIndexed(_indexCount, 0, 0);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public:
|
|||||||
void render(ID3D11DeviceContext* pD3DDeviceContext);
|
void render(ID3D11DeviceContext* pD3DDeviceContext);
|
||||||
void deInit();
|
void deInit();
|
||||||
|
|
||||||
|
const XMFLOAT4X4& getWorldMatrix() const { return _worldMatrix; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT createVertexBuffer(ID3D11Device* pD3DDevice);
|
UINT createVertexBuffer(ID3D11Device* pD3DDevice);
|
||||||
UINT createIndexBuffer(ID3D11Device* pD3DDevice);
|
UINT createIndexBuffer(ID3D11Device* pD3DDevice);
|
||||||
|
|||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
float4 main() : SV_TARGET
|
float4 main() : SV_TARGET
|
||||||
{
|
{
|
||||||
return float4(1.0f, 1.0f, 1.0f, 1.0f);
|
return float4(1.0f, .0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
+11
-23
@@ -1,36 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <d3d9.h>
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
#define FVF D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_NORMAL
|
using namespace DirectX;
|
||||||
|
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
// position
|
XMFLOAT3 position;
|
||||||
float x;
|
XMFLOAT3 normal;
|
||||||
float y;
|
XMFLOAT2 uv;
|
||||||
float z;
|
XMFLOAT4 color;
|
||||||
|
|
||||||
// normal
|
Vertex() : position(0.0f, 0.0f, 0.0f), color(1.0f, 1.0f, 1.0f, 1.0f), uv(0.0f, 0.0f), normal(0.0f, 0.0f, 0.0f) {}
|
||||||
float nx;
|
Vertex(float x, float y, float z) : position(x, y, z), color(1.0f, 1.0f, 1.0f, 1.0f), uv(0.0f, 0.0f), normal(0.0f, 0.0f, 0.0f) {}
|
||||||
float ny;
|
|
||||||
float nz;
|
|
||||||
|
|
||||||
// color
|
|
||||||
D3DCOLOR color;
|
|
||||||
|
|
||||||
// texture coordinates
|
|
||||||
float u;
|
|
||||||
float v;
|
|
||||||
|
|
||||||
Vertex() : x(0.0f), y(0.0f), z(0.0f), color(0xffffffff), u(0.0f), v(0.0f), nx(0.0f), ny(0.0f), nz(0.0f) {}
|
|
||||||
Vertex(float x, float y, float z) : x(x), y(y), z(z), color(0xffffffff), u(0.0f), v(0.0f), nx(0.0f), ny(0.0f), nz(0.0f) {}
|
|
||||||
|
|
||||||
Vertex(float x, float y, float z, UINT r, UINT g, UINT b) :
|
Vertex(float x, float y, float z, UINT r, UINT g, UINT b) :
|
||||||
x(x), y(y), z(z), color(D3DCOLOR_XRGB(r, g, b)), u(0.0f), v(0.0f), nx(0.0f), ny(0.0f), nz(0.0f) {}
|
position(x, y, z), color(1.0f, 1.0f, 1.0f, 1.0f), uv(0.0f, 0.0f), normal(0.0f, 0.0f, 0.0f) {}
|
||||||
|
|
||||||
Vertex(float x, float y, float z, float u, float v) :
|
Vertex(float x, float y, float z, float u, float v) :
|
||||||
x(x), y(y), z(z), color(0xffffffff), u(u), v(v), nx(0.0f), ny(0.0f), nz(0.0f) {}
|
position(x, y, z), color(1.0f, 1.0f, 1.0f, 1.0f), uv(u, v), normal(0.0f, 0.0f, 0.0f) {}
|
||||||
|
|
||||||
Vertex(float x, float y, float z, float nx, float ny, float nz, float u, float v) :
|
Vertex(float x, float y, float z, float nx, float ny, float nz, float u, float v) :
|
||||||
x(x), y(y), z(z), color(0xffffffff), u(u), v(v), nx(nx), ny(ny), nz(nz) {}
|
position(x, y, z), color(1.0f, 1.0f, 1.0f, 1.0f), uv(u, v), normal(nx, ny, nz) {}
|
||||||
};
|
};
|
||||||
Binary file not shown.
@@ -1,4 +1,9 @@
|
|||||||
|
cbuffer MatrixBuffer
|
||||||
|
{
|
||||||
|
float4x4 WorldViewProjectionMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
float4 main( float4 pos : POSITION ) : SV_POSITION
|
float4 main( float4 pos : POSITION ) : SV_POSITION
|
||||||
{
|
{
|
||||||
return pos;
|
return mul(pos, WorldViewProjectionMatrix);
|
||||||
}
|
}
|
||||||
+9
-6
@@ -37,10 +37,10 @@ int WINAPI WinMain(
|
|||||||
error = mesh.init(d3d.getDevice());
|
error = mesh.init(d3d.getDevice());
|
||||||
CheckError(error);
|
CheckError(error);
|
||||||
|
|
||||||
//// 4. create a camera
|
// 4. create a camera
|
||||||
//Camera camera = {};
|
Camera camera = {};
|
||||||
//error = camera.init(d3d.getDevice(), width, height);
|
error = camera.init(width, height);
|
||||||
//CheckError(error);
|
CheckError(error);
|
||||||
|
|
||||||
// 5. create time
|
// 5. create time
|
||||||
Time time = {};
|
Time time = {};
|
||||||
@@ -75,14 +75,17 @@ int WINAPI WinMain(
|
|||||||
// 8.1. update objects
|
// 8.1. update objects
|
||||||
time.update();
|
time.update();
|
||||||
mesh.update(time.getDeltaTime());
|
mesh.update(time.getDeltaTime());
|
||||||
//camera.update(time.getDeltaTime());
|
camera.update(time.getDeltaTime());
|
||||||
//light.update(time.getDeltaTime());
|
//light.update(time.getDeltaTime());
|
||||||
|
|
||||||
|
material.setMatrices(
|
||||||
|
d3d.getDeviceContext(), mesh.getWorldMatrix(), camera.getViewMatrix(), camera.getProjectionMatrix());
|
||||||
|
|
||||||
// 8.2. render objects
|
// 8.2. render objects
|
||||||
d3d.beginScene();
|
d3d.beginScene();
|
||||||
|
|
||||||
//light.render(d3d.getDevice());
|
//light.render(d3d.getDevice());
|
||||||
material.render(d3d.getDevice());
|
material.render(d3d.getDeviceContext());
|
||||||
mesh.render(d3d.getDeviceContext());
|
mesh.render(d3d.getDeviceContext());
|
||||||
|
|
||||||
d3d.endScene();
|
d3d.endScene();
|
||||||
|
|||||||
Reference in New Issue
Block a user