mirror of
https://github.com/rrika/cdcEngineDXHR.git
synced 2024-11-23 21:49:54 +00:00
add PCDX11SimpleDynamicVertexBuffer
This commit is contained in:
parent
28a03b1e1b
commit
47340389c1
@ -15,6 +15,7 @@
|
||||
#include "PCDX11StateManager.h"
|
||||
#include "RenderPasses.h"
|
||||
#include "Types.h"
|
||||
#include "buffers/PCDX11SimpleDynamicVertexBuffer.h"
|
||||
#include "shaders/PCDX11ShaderLib.h"
|
||||
#include "surfaces/PCDX11DefaultRenderTarget.h"
|
||||
#include "surfaces/PCDX11DepthBuffer.h"
|
||||
|
46
rendering/buffers/PCDX11SimpleDynamicVertexBuffer.h
Normal file
46
rendering/buffers/PCDX11SimpleDynamicVertexBuffer.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include "PCDX11VertexBuffer.h"
|
||||
#include "../PCDX11DeviceManager.h"
|
||||
#include <d3d11.h>
|
||||
|
||||
namespace cdc {
|
||||
|
||||
class PCDX11SimpleDynamicVertexBuffer :
|
||||
public PCDX11VertexBuffer
|
||||
{
|
||||
public:
|
||||
PCDX11SimpleDynamicVertexBuffer(uint32_t stride, uint32_t numVertices) :
|
||||
stride(stride),
|
||||
numVertices(numVertices)
|
||||
{
|
||||
D3D11_BUFFER_DESC vertexBufferDesc = {};
|
||||
vertexBufferDesc.ByteWidth = stride * numVertices;
|
||||
vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
deviceManager->getD3DDevice()->CreateBuffer(&vertexBufferDesc, nullptr, &buffer);
|
||||
}
|
||||
|
||||
uint32_t stride; // 4
|
||||
uint32_t numVertices; // 8
|
||||
ID3D11Buffer *buffer; // C
|
||||
|
||||
uint32_t getBaseVertex() override { return 0; }
|
||||
ID3D11Buffer *getD3DBuffer() override { return buffer; }
|
||||
uint32_t method0C() override { return numVertices; }
|
||||
uint32_t getStride() override { return stride; }
|
||||
void method14() override {}
|
||||
|
||||
void *map() {
|
||||
D3D11_MAPPED_SUBRESOURCE subresourceData;
|
||||
deviceManager->getD3DDeviceContext()->Map(
|
||||
buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &subresourceData);
|
||||
return subresourceData.pData;
|
||||
}
|
||||
|
||||
void unmap() {
|
||||
deviceManager->getD3DDeviceContext()->Unmap(buffer, 0);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user