mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-04 18:57:59 +03:00
20 lines
578 B
C++
20 lines
578 B
C++
![]() |
#include "IndexBuffer.h"
|
||
|
|
||
|
using Microsoft::WRL::ComPtr;
|
||
|
using T5M::Renderer::Utils::throwIfFailed;
|
||
|
|
||
|
IndexBuffer::IndexBuffer(ID3D11Device* device, int numIndices, int* indices)
|
||
|
{
|
||
|
HRESULT res;
|
||
|
D3D11_BUFFER_DESC desc = {};
|
||
|
|
||
|
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));
|
||
|
}
|