Start aligning Dx and OpenGl approaches.
This commit is contained in:
parent
d1ec8b4f68
commit
d99a36f24f
22 changed files with 899 additions and 366 deletions
60
src/graphics/directx/DirectXMeshPainter.h
Normal file
60
src/graphics/directx/DirectXMeshPainter.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
|
||||
#include <wrl.h>
|
||||
#include <directxmath.h>
|
||||
#include <d3d12.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class DrawingContext;
|
||||
class DirectXShaderProgram;
|
||||
class SceneModel;
|
||||
|
||||
struct CD3DX12_CPU_DESCRIPTOR_HANDLE;
|
||||
|
||||
class DirectXMeshPainter
|
||||
{
|
||||
public:
|
||||
DirectXMeshPainter();
|
||||
|
||||
void paint(SceneModel* model, DrawingContext* context);
|
||||
|
||||
DirectXShaderProgram* getShaderProgram() const;
|
||||
|
||||
void createVertexBuffer(ID3D12Device* device);
|
||||
void createRootSignature(ID3D12Device* device);
|
||||
void createPipelineStateObject(ID3D12Device* device);
|
||||
|
||||
ID3D12PipelineState* getPipelineState() const;
|
||||
ID3D12RootSignature* getRootSignature() const;
|
||||
|
||||
void updateCommandList(const CD3DX12_CPU_DESCRIPTOR_HANDLE& rtvHandle, ID3D12GraphicsCommandList* commandList);
|
||||
|
||||
private:
|
||||
struct Vertex
|
||||
{
|
||||
DirectX::XMFLOAT3 position;
|
||||
DirectX::XMFLOAT4 color;
|
||||
};
|
||||
|
||||
void initializeShader();
|
||||
void initializeBuffers();
|
||||
|
||||
unsigned int getVertexBufferSize() const;
|
||||
unsigned int getVertexSize() const;
|
||||
void updateVertexBuffer(unsigned char* pBuffer) const;
|
||||
|
||||
void paint(const std::vector<float>& verts, const std::vector<unsigned>& elements, const std::vector<float>& color, bool lines = false);
|
||||
|
||||
unsigned int mVertexBufferSize{ 0 };
|
||||
std::vector<Vertex> mVertexBuffer;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> mD3dVertexBuffer;
|
||||
D3D12_VERTEX_BUFFER_VIEW mVertexBufferView{};
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12RootSignature> mRootSignature;
|
||||
Microsoft::WRL::ComPtr<ID3D12PipelineState> mPipelineState;
|
||||
|
||||
std::unique_ptr<DirectXShaderProgram> mShaderProgram;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue