-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMesh.cpp
More file actions
104 lines (69 loc) · 2.01 KB
/
Mesh.cpp
File metadata and controls
104 lines (69 loc) · 2.01 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "stdafx.h"
#include "Mesh.h"
#include "LogManager.h"
//#include <assimp/Importer.hpp>
//#include <assimp/scene.h>
//#include <assimp/postprocess.h>
//#include <vector>
//#include <sstream>
#include <iostream>
Mesh::Mesh(unsigned int vertexCount, vertex* vertexArray, unsigned int indexCount, GLuint* indexArray, Material* material, GLuint usage) {
m_iVertexCount = vertexCount;
//m_xVertices = vertexArray;
m_iIndexCount = indexCount;
//m_iIndices = indexArray;
m_xMaterial = material;
glGenBuffers(2, (GLuint*)&m_xGLBuffers);
glBindBuffer(GL_ARRAY_BUFFER, m_xGLBuffers.vertex);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_xGLBuffers.index);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex) * m_iVertexCount, vertexArray, usage);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * m_iIndexCount, indexArray, usage);
}
Mesh::~Mesh() {
/* MeshManger handles cleanup */
//delete [] m_xVertices;
//delete [] m_iIndices;
glDeleteBuffers(2, (GLuint*)&m_xGLBuffers);
}
unsigned int Mesh::getVertexCount() const {
return m_iVertexCount;
}
unsigned int Mesh::getIndexCount() const {
return m_iIndexCount;
}
unsigned int Mesh::getTriCount() const {
return m_iIndexCount / 3;
}
Material* Mesh::getMaterial() {
return m_xMaterial;
}
/*vertex* Mesh::getVertexArray() const {
return m_xVertices;
}
GLuint* Mesh::getIndexArray() const {
return m_iIndices;
}*/
GLuint Mesh::getVertexBufferID() const {
return m_xGLBuffers.vertex;
}
GLuint Mesh::getIndexBufferID() const {
return m_xGLBuffers.index;
}
void Mesh::setMaterial( Material* material ){
m_xMaterial = material;
}
/*void Mesh::setVertexArray( unsigned int vertCount, vertex* vertexArray ) {
if(m_xVertices != nullptr)
delete[] m_xVertices;
m_iVertexCount = vertCount;
m_xVertices = vertexArray;
}
void Mesh::setIndexArray( unsigned int indicesCount, GLuint* indexArray ) {
if(m_iIndices != nullptr)
delete[] m_iIndices;
m_iIndexCount = indicesCount;
m_iIndices = indexArray;
}*/
/*bool Mesh::isDummy() {
return m_iVertexCount == 0;
}*/