Initial commit

This commit is contained in:
plane000
2018-09-16 14:02:14 +01:00
parent a3b712b6b7
commit 32d9ad1dea
11 changed files with 443 additions and 4 deletions

29
OpenGL/mesh.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include "mesh.h"
Mesh::Mesh(GLfloat *vertices, unsigned int numVerticies) {
m_drawCount = numVerticies;
glGenVertexArrays(1, &m_VAO);
glBindVertexArray(m_VAO);
glGenBuffers(NUM_BUFFERS, m_VBO);
glBindBuffer(GL_ARRAY_BUFFER, m_VBO[POSITION_VB]);
glBufferData(GL_ARRAY_BUFFER, numVerticies * sizeof(vertices[0]), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
std::cout << "Mesh loaded successfully" << std::endl;
}
void Mesh::Draw() {
glBindVertexArray(m_VAO);
glDrawArrays(GL_TRIANGLES, 0, m_drawCount);
glBindVertexArray(0);
}
Mesh::~Mesh() {
glDeleteVertexArrays(1, &m_VAO);
}