-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexBuffer.cpp
More file actions
25 lines (21 loc) · 788 Bytes
/
IndexBuffer.cpp
File metadata and controls
25 lines (21 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "IndexBuffer.h"
#include "GraphicsMacros.h"
IndexBuffer::IndexBuffer(Graphics& gfx, const std::vector<unsigned short>& indices) : count((UINT)indices.size()){
INFOMAN(gfx);
D3D11_BUFFER_DESC ibd = {};
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
ibd.Usage = D3D11_USAGE_DEFAULT;
ibd.CPUAccessFlags = 0u;
ibd.MiscFlags = 0u;
ibd.ByteWidth = UINT(this->count * sizeof(unsigned short));
ibd.StructureByteStride = sizeof(unsigned short);
D3D11_SUBRESOURCE_DATA isd = {};
isd.pSysMem = indices.data();
GFX_THROW_INFO(GetDevice(gfx)->CreateBuffer(&ibd, &isd, &pIndexBuffer));
}
void IndexBuffer::Bind(Graphics& gfx) noexcept {
GetContext(gfx)->IASetIndexBuffer(pIndexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0u);
}
UINT IndexBuffer::GetCount() const noexcept {
return count;
}