-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeshGeometry.cpp
More file actions
executable file
·45 lines (33 loc) · 1.05 KB
/
MeshGeometry.cpp
File metadata and controls
executable file
·45 lines (33 loc) · 1.05 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
#include "MeshGeometry.h"
MeshGeometry::MeshGeometry():mVB(0),mIB(0),mIndexBufferFormat(DXGI_FORMAT_R16_UINT),mVertexStride(0)
{
}
MeshGeometry::~MeshGeometry(void)
{
ReleaseCOM(mVB);
ReleaseCOM(mIB);
}
void MeshGeometry::SetIndices(ID3D11Device* device, const USHORT* indices, UINT count)
{
D3D11_BUFFER_DESC ibd;
ibd.Usage = D3D11_USAGE_IMMUTABLE;
ibd.ByteWidth = sizeof(USHORT)*count;
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
ibd.CPUAccessFlags = 0;
ibd.MiscFlags = 0;
ibd.StructureByteStride = 0;
D3D11_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = indices;
HR(device->CreateBuffer(&ibd,&iinitData,&mIB));
}
void MeshGeometry::SetSubsetTable(std::vector<MeshGeometry::Subset>& subsetTable)
{
mSubsetTable = subsetTable;
}
void MeshGeometry::Draw(ID3D11DeviceContext* dc, UINT subsetId)
{
UINT offset = 0;
dc->IASetVertexBuffers(0,1,&mVB,&mVertexStride,&offset);
dc->IASetIndexBuffer(mIB,mIndexBufferFormat,0);
dc->DrawIndexed(mSubsetTable[subsetId].FaceCount*3,mSubsetTable[subsetId].FaceStart*3,0);
}