-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmesh.h
54 lines (43 loc) · 1.02 KB
/
mesh.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
#ifndef MESH_H
#define MESH_H
#include "geometry.h"
#include "common.h"
#include "sceneobject.h"
struct SimpleVertex {
vec3 position;
vec3 normal;
vec2 uv;
};
struct VertexBufferDesc
{
const void* bufferData;
uint32_t bufferSize = 0;
vector<uint8_t> vertexElementSizes;
uint32_t stride = 0;
};
enum class PrimitiveType
{
Points,
Lines,
Triangles,
Patches,
};
typedef vector<uint16_t> IndexBuffer;
class Mesh
{
public:
Mesh();
~Mesh();
void render() const;
// Mesh doesn't own vertex buffer and index buffer, callers are responsible for releasing them
void setVertexBuffer(const VertexBufferDesc& vertexBuffer,
PrimitiveType primitveType);
void setIndexBuffer(const IndexBuffer& indexBuffer);
private:
uint32_t vertexArrayObject_ = 0;
uint32_t vertexBufferObject_ = 0;
uint32_t indexBufferObject_ = 0;
PrimitiveType primitiveType_ = PrimitiveType::Triangles;
int numElements_ = 0;
};
#endif // MESH_H