-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeshData.h
56 lines (39 loc) · 1.36 KB
/
MeshData.h
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
54
55
#pragma once
#include "VertexStructs.h"
#include "Logger.h"
class MeshData
{
public:
MeshData(std::vector<VertexBase> vertices, std::vector<DWORD> indices);
~MeshData();
MeshData(const MeshData& obj) = delete;
MeshData& operator=(const MeshData& obj) = delete;
UINT GetVertexCount() const { return static_cast<UINT>(m_Vertices.size()); }
UINT GetIndexCount() const { return static_cast<UINT>(m_Indices.size()); }
ID3D11Buffer* GetIndexBuffer();
template<typename T>
ID3D11Buffer* GetVertexBuffer()
{
const type_info &type = typeid(T);
if(type == typeid(VertexPosColNorm))
return GetVertexBuffer_PosNormCol();
if(type == typeid(VertexPosColNormTex))
return GetVertexBuffer_PosNormColTex();
if(type == typeid(VertexPosNormTex))
return GetVertexBuffer_PosNormTex();
std::wstringstream ss;
ss<<L"MeshData::GetVertexBuffer<"<<type.name()<<L">(): No implementation found for \'"<<type.name()<<L"\'!";
Logger::GetInstance()->LogWarning(ss.str());
return nullptr;
}
private:
ID3D11Buffer* m_pIndexBuffer;
ID3D11Buffer* m_pVertexBuffer_PosNormCol;
ID3D11Buffer* GetVertexBuffer_PosNormCol();
ID3D11Buffer* m_pVertexBuffer_PosNormColTex;
ID3D11Buffer* GetVertexBuffer_PosNormColTex();
ID3D11Buffer* m_pVertexBuffer_PosNormTex;
ID3D11Buffer* GetVertexBuffer_PosNormTex();
std::vector<VertexBase> m_Vertices;
std::vector<DWORD> m_Indices;
};