-
Notifications
You must be signed in to change notification settings - Fork 1
/
mesh.h
49 lines (38 loc) · 894 Bytes
/
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
#ifndef __MESH_H__
#define __MESH_H__
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <vector>
/* Simple 3D mesh */
class Mesh {
private:
/* Vertex */
typedef struct {
GLfloat x;
GLfloat y;
GLfloat z;
} vertex_t;
/* Triangle */
typedef struct {
GLushort a;
GLushort b;
GLushort c;
} triangle_t;
/* Buffers to store 3d-data */
std::vector<vertex_t> vertices;
std::vector<triangle_t> triangles;
public:
Mesh() {}
virtual ~Mesh() {}
/* Load mesh from a file */
void load(const char* file);
/* Load vertex data into EGL buffer */
GLuint genVertexBuffer();
/* Load index (triangle) data into EGL buffer */
GLuint genTrianglesBuffer();
/* Number of vertices/triangles */
GLsizei getVertexNum();
GLsizei getTrianglesNum();
};
#endif