2020-06-16 15:11:30 +02:00
|
|
|
#include "IndexBuffer.h"
|
2021-08-20 05:25:51 +02:00
|
|
|
namespace ten::renderer {
|
2020-06-21 14:27:12 +02:00
|
|
|
using Microsoft::WRL::ComPtr;
|
2021-08-20 05:25:51 +02:00
|
|
|
using ten::renderer::Utils::throwIfFailed;
|
2020-06-16 15:11:30 +02:00
|
|
|
|
2020-06-21 14:27:12 +02:00
|
|
|
IndexBuffer::IndexBuffer(ID3D11Device* device, int numIndices, int* indices) {
|
|
|
|
HRESULT res;
|
|
|
|
D3D11_BUFFER_DESC desc = {};
|
2020-06-16 15:11:30 +02:00
|
|
|
|
2020-06-21 14:27:12 +02:00
|
|
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
|
|
|
desc.ByteWidth = sizeof(int) * numIndices;
|
|
|
|
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
|
|
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
|
|
|
D3D11_SUBRESOURCE_DATA initData = {};
|
|
|
|
initData.pSysMem = indices;
|
|
|
|
initData.SysMemPitch = sizeof(int) * numIndices;
|
|
|
|
throwIfFailed(device->CreateBuffer(&desc, &initData, &Buffer));
|
|
|
|
}
|
2020-06-16 15:11:30 +02:00
|
|
|
|
|
|
|
}
|