60 lines
No EOL
1.6 KiB
C++
60 lines
No EOL
1.6 KiB
C++
#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;
|
|
}; |