Add input layout

Add matrix buffer
Convert camera to D3D11
This commit is contained in:
2026-11-27 16:08:22 +01:00
parent 85d8830b84
commit 97192e1587
12 changed files with 171 additions and 69 deletions
+4 -13
View File
@@ -1,10 +1,6 @@
#include "Camera.h"
#include <DirectXMath.h>
using namespace DirectX;
UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
UINT Camera::init(UINT width, UINT height)
{
// view matrix
XMVECTOR position = XMVectorSet(0.0f, 0.0f, -1.0f, 0.0f);
@@ -12,10 +8,8 @@ UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
XMMATRIX lookTo = XMMatrixLookToLH(position, forward, up);
XMFLOAT4X4 v;
XMStoreFloat4x4(&v, lookTo);
_viewMatrix = *reinterpret_cast<D3DMATRIX*>(&v);
XMStoreFloat4x4(&_viewMatrix, lookTo);
// projection matrix
float fov = XMConvertToRadians(60.0f);
float aspectRatio = static_cast<float>(width) / static_cast<float>(height);
@@ -23,10 +17,7 @@ UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
float farClippingPlane = 100.0f;
XMMATRIX perspective = XMMatrixPerspectiveFovLH(fov, aspectRatio, nearClippingPlane, farClippingPlane);
XMStoreFloat4x4(reinterpret_cast<XMFLOAT4X4*>(&_projectionMatrix), perspective);
pD3DDevice->SetTransform(D3DTS_VIEW, &_viewMatrix);
pD3DDevice->SetTransform(D3DTS_PROJECTION, &_projectionMatrix);
XMStoreFloat4x4(&_projectionMatrix, perspective);
return 0;
}