Start converting D3D9 to D3D11
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#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);
|
||||
XMFLOAT4X4 p;
|
||||
XMStoreFloat4x4(&p, perspective);
|
||||
_projectionMatrix = *reinterpret_cast<D3DMATRIX*>(&p);
|
||||
|
||||
pD3DDevice->SetTransform(D3DTS_VIEW, &_viewMatrix);
|
||||
pD3DDevice->SetTransform(D3DTS_PROJECTION, &_projectionMatrix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Camera::update(FLOAT dt)
|
||||
{
|
||||
}
|
||||
|
||||
void Camera::deInit()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user