Initial directx example.

This commit is contained in:
jmsgrogan 2023-01-03 20:33:18 +00:00
parent 1dfbcc61c4
commit 92d1f24613
28 changed files with 683 additions and 212 deletions

View file

@ -0,0 +1,87 @@
#pragma once
#include <memory>
#include <wrl.h>
#include <d3d12.h>
#include <directxmath.h>
#include <directx/d3dx12.h>
class Win32DxInterface;
namespace mt
{
class Window;
}
struct ID3D12CommandQueue;
struct ID3D12CommandAllocator;
struct ID3D12GraphicsCommandList;
struct IDXGISwapChain4;
struct ID3D12DescriptorHeap;
struct ID3D12Resource;
struct ID3D12Fence;
struct ID3D12RootSignature;
struct ID3D12PipelineState;
class Win32DxWindowInterface
{
public:
Win32DxWindowInterface(Win32DxInterface* dxInterface);
~Win32DxWindowInterface();
bool initialize(mt::Window* window);
void onRender();
//void afterPaint();
//void resizeViewPort(unsigned width, unsigned height);
private:
void loadPipeline(mt::Window* window);
void loadAssets();
void populateCommandList();
void waitForPreviousFrame();
void destroyWindow();
static const UINT FrameCount = 2;
Win32DxInterface* mDxInterface{ nullptr };
bool mInitialized{ false };
struct Vertex
{
DirectX::XMFLOAT3 position;
DirectX::XMFLOAT4 color;
};
CD3DX12_VIEWPORT mViewport;
CD3DX12_RECT mScissorRect;
Microsoft::WRL::ComPtr<ID3D12CommandQueue> mCommandQueue;
Microsoft::WRL::ComPtr<ID3D12CommandAllocator> mCommandAllocator;
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList> mCommandList;
Microsoft::WRL::ComPtr<IDXGISwapChain4> mSwapChain;
Microsoft::WRL::ComPtr<ID3D12RootSignature> mRootSignature;
Microsoft::WRL::ComPtr<ID3D12PipelineState> mPipelineState;
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mRtvHeap;
UINT mRtvDescriptorSize{ 0 };
Microsoft::WRL::ComPtr<ID3D12Resource> mRenderTargets[FrameCount];
Microsoft::WRL::ComPtr<ID3D12Resource> mVertexBuffer;
D3D12_VERTEX_BUFFER_VIEW mVertexBufferView{};
Microsoft::WRL::ComPtr<ID3D12Fence> mFence;
uint64_t mFenceValue = 0;
uint64_t mFrameFenceValues[FrameCount] = {};
HANDLE mFenceEvent{};
uint64_t mFrameIndex{ 0 };
};
using XcbGlWindowInterfacePtr = std::unique_ptr<Win32DxWindowInterface>;