Add D3D11 project

This commit is contained in:
2026-11-23 13:32:53 +01:00
parent abf85aa6f7
commit 024a283898
24 changed files with 1793 additions and 1 deletions
+40
View File
@@ -0,0 +1,40 @@
#include "Camera.h"
#include <DirectXMath.h>
using namespace DirectX;
UINT Camera::init(IDirect3DDevice9* pD3DDevice, UINT width, UINT height)
{
// view matrix
XMVECTOR position = XMVectorSet(0.0f, 0.0f, -1.0f, 0.0f);
XMVECTOR forward = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
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);
// projection matrix
float fov = XMConvertToRadians(60.0f);
float aspectRatio = static_cast<float>(width) / static_cast<float>(height);
float nearClippingPlane = 0.3f;
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);
return 0;
}
void Camera::update(FLOAT dt)
{
}
void Camera::deInit()
{
}