Add a basic entity class
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
#include "Mesh.h"
|
||||
|
||||
Mesh::Mesh(std::vector<Vertex> vertices, std::vector<uint32_t> indices, std::vector<Texture*> textures)
|
||||
: vertices(vertices),
|
||||
indices(indices),
|
||||
: numElements(indices.size()),
|
||||
textures(textures),
|
||||
vertexBuffer(static_cast<void*>(vertices.data()), static_cast<void*>(indices.data()), vertices.size(), indices.size()) {
|
||||
|
||||
// Empty...
|
||||
|
||||
}
|
||||
|
||||
void Mesh::draw(ShaderProgram *shaderProgram) {
|
||||
|
||||
uint8_t typeNumberCount[TEXTURE_TYPE_NUM_ITEMS] {0};
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
// Bind all textures in order to its texture unit
|
||||
for(auto it = textures.begin(); it != textures.end(); it++) {
|
||||
int i = it - textures.begin();
|
||||
@@ -26,7 +26,7 @@ void Mesh::draw(ShaderProgram *shaderProgram) {
|
||||
|
||||
// Draw elements
|
||||
vertexBuffer.bind();
|
||||
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
|
||||
glDrawElements(GL_TRIANGLES, numElements, GL_UNSIGNED_INT, 0);
|
||||
vertexBuffer.unbind();
|
||||
|
||||
// Unbind all textures
|
||||
|
||||
Reference in New Issue
Block a user