-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexBuffer.cpp
More file actions
53 lines (43 loc) · 1.08 KB
/
IndexBuffer.cpp
File metadata and controls
53 lines (43 loc) · 1.08 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "IndexBuffer.h"
#include "GraphicsEngine.h"
#include <iostream>
IndexBuffer::IndexBuffer()
{
}
IndexBuffer::~IndexBuffer()
{
}
void IndexBuffer::load(void* indexList, UINT listSize)
{
if (this->buffer) this->buffer->Release();
D3D11_BUFFER_DESC bufferDesc = {};
bufferDesc.Usage = D3D11_USAGE_DEFAULT;
bufferDesc.ByteWidth = 4 * listSize;
bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
bufferDesc.CPUAccessFlags = 0;
bufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA initData = {};
initData.pSysMem = indexList;
this->listSize = listSize;
ID3D11Device* directXDevice = GraphicsEngine::get()->getDirect3DDevice();
HRESULT bufferResult = directXDevice->CreateBuffer(&bufferDesc, &initData, &this->buffer);
if (SUCCEEDED(bufferResult)) {
std::cout << "Creation of index buffer succeeded. \n";
}
else {
std::cout << "An error occurred in creating a index buffer. \n";
}
}
void IndexBuffer::release()
{
this->buffer->Release();
delete this;
}
ID3D11Buffer* IndexBuffer::getBuffer()
{
return this->buffer;
}
UINT IndexBuffer::getIndexSize()
{
return this->listSize;
}