Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/framework/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ using namespace glm;
void Mesh::load(const std::vector<float>& vertices, const std::vector<unsigned int>& indices) {
// Load data into buffers
numIndices = indices.size();
#ifndef MODERN_GL
vao.bind();
#endif
vbo.load(vertices, GL_STATIC_DRAW);
ebo.load(indices, GL_STATIC_DRAW);

Expand All @@ -30,7 +33,6 @@ void Mesh::load(const std::vector<float>& vertices, const std::vector<unsigned i
glEnableVertexArrayAttrib(vao.handle, 0);
glVertexArrayAttribBinding(vao.handle, 0, 0);
#else
vao.bind();
vbo.bind();
ebo.bind();
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, 0);
Expand All @@ -41,6 +43,9 @@ void Mesh::load(const std::vector<float>& vertices, const std::vector<unsigned i
void Mesh::load(const std::vector<float>& vertices, const std::vector<unsigned int>& attributeSizes, const std::vector<unsigned int>& indices) {
// Load data into buffers
numIndices = indices.size();
#ifndef MODERN_GL
vao.bind(); // NOTE: Bind VAO first as Core Profile requires a VAO to be bound when loading buffers
#endif
Comment on lines +46 to +48
vbo.load(vertices, GL_STATIC_DRAW);
ebo.load(indices, GL_STATIC_DRAW);

Expand All @@ -62,7 +67,6 @@ void Mesh::load(const std::vector<float>& vertices, const std::vector<unsigned i
glVertexArrayVertexBuffer(vao.handle, 0, vbo.handle, 0, stride);
glVertexArrayElementBuffer(vao.handle, ebo.handle);
#else
vao.bind();
vbo.bind();
ebo.bind();
GLuint offset = 0;
Expand All @@ -78,6 +82,9 @@ void Mesh::load(const std::vector<float>& vertices, const std::vector<unsigned i
void Mesh::load(const std::vector<VertexPC>& vertices, const std::vector<unsigned int>& indices) {
// Load data into buffers
numIndices = indices.size();
#ifndef MODERN_GL
vao.bind(); // NOTE: Bind VAO first as Core Profile requires a VAO to be bound when loading buffers
#endif
Comment on lines +85 to +87
vbo.load(vertices, GL_STATIC_DRAW);
ebo.load(indices, GL_STATIC_DRAW);

Expand All @@ -94,7 +101,6 @@ void Mesh::load(const std::vector<VertexPC>& vertices, const std::vector<unsigne
glVertexArrayAttribBinding(vao.handle, 0, 0);
glVertexArrayAttribBinding(vao.handle, 1, 0);
#else
vao.bind();
vbo.bind();
ebo.bind();
// Vertex attributes
Expand All @@ -110,6 +116,9 @@ void Mesh::load(const std::vector<VertexPC>& vertices, const std::vector<unsigne
void Mesh::load(const std::vector<VertexPTN>& vertices, const std::vector<unsigned int>& indices) {
// Load data into buffers
numIndices = indices.size();
#ifndef MODERN_GL
vao.bind(); // NOTE: Bind VAO first as Core Profile requires a VAO to be bound when loading buffers
#endif
Comment on lines +119 to +121
vbo.load(vertices, GL_STATIC_DRAW);
ebo.load(indices, GL_STATIC_DRAW);

Expand All @@ -129,7 +138,6 @@ void Mesh::load(const std::vector<VertexPTN>& vertices, const std::vector<unsign
glVertexArrayAttribBinding(vao.handle, 1, 0);
glVertexArrayAttribBinding(vao.handle, 2, 0);
#else
vao.bind();
vbo.bind();
ebo.bind();
// Vertex attributes
Expand All @@ -148,6 +156,9 @@ void Mesh::load(const std::vector<VertexPTN>& vertices, const std::vector<unsign
void Mesh::load(const std::vector<VertexPTNT>& vertices, const std::vector<unsigned int>& indices) {
// Load data into buffers
numIndices = indices.size();
#ifndef MODERN_GL
vao.bind(); // NOTE: Bind VAO first as Core Profile requires a VAO to be bound when loading buffers
#endif
Comment on lines +159 to +161
vbo.load(vertices, GL_STATIC_DRAW);
ebo.load(indices, GL_STATIC_DRAW);

Expand All @@ -170,7 +181,6 @@ void Mesh::load(const std::vector<VertexPTNT>& vertices, const std::vector<unsig
glVertexArrayAttribBinding(vao.handle, 2, 0);
glVertexArrayAttribBinding(vao.handle, 3, 0);
#else
vao.bind();
vbo.bind();
ebo.bind();
// Vertex attributes
Expand Down