-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmesh.h
53 lines (42 loc) · 1.43 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
#pragma once
#include <GL/glew.h>
#include <iostream>
/**
* @brief Class Mesh handles mesh operations such as creating new mesh, rendering, and clearing mesh.
*/
class Mesh
{
public:
/**
* @brief Constructor to build new Mesh object from vertices and their size.
* @param vertices Vertices (points) of mesh in space.
* @param verticesSize Size of vertices in memory.
*/
Mesh(GLfloat *vertices, int verticesSize, GLfloat *colors, int colorsSize, GLfloat *textureCoordinates, int textureCoordinatesSize, unsigned int *indices, int indicesSize, GLenum type, bool normalize, GLsizei stride);
/**
* @brief Destructor.
*/
~Mesh();
// Methods
/**
* @brief Initialise mesh object
*/
void initialise(GLenum type, bool normalize);
void addAttribute(int index, GLenum target, int vertexSize, GLenum type, bool normalize, void *data, int dataSize, GLuint *buffer);
void unbind();
/**
* @brief Render mesh.
*/
void render(GLenum mode, GLsizei count, GLenum type, const void *indices);
void copy(GLenum mode, GLsizei count, GLenum type, const void *indices);
/**
* @brief Clear mesh.
*/
void clear();
// Fields
GLuint vertexArray, vertexBuffer, colorBuffer, textureBuffer, elementBuffer;
private:
GLfloat *vertices, *colors, *textureCoordinates;
int verticesSize, colorsSize, textureCoordinatesSize, indicesSize;
GLuint *indices;
};