summary refs log tree commit diff
path: root/src/Binder.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-10-10 16:23:26 +0200
committerMel <einebeere@gmail.com>2022-10-10 16:23:26 +0200
commitcb3ddae385c03a8830d39dc37fcd5bf273524d5e (patch)
tree0ccddcd6b32838b8fc2b65805a4fba96c4c0ff39 /src/Binder.cpp
parent799c06e0387e01bdb8a10019be6192f9db00a824 (diff)
downloadmeowcraft-cb3ddae385c03a8830d39dc37fcd5bf273524d5e.tar.zst
meowcraft-cb3ddae385c03a8830d39dc37fcd5bf273524d5e.zip
Try to add second VBO
Diffstat (limited to 'src/Binder.cpp')
-rw-r--r--src/Binder.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Binder.cpp b/src/Binder.cpp
index 409c4ef..9bca480 100644
--- a/src/Binder.cpp
+++ b/src/Binder.cpp
@@ -8,6 +8,7 @@ BindableMesh Binder::load(Mesh& mesh) {
     auto vao = create_vao();
     store_indices(mesh.raw_indices(), mesh.indices_size());
     store_in_attribute_list(0, 3, mesh.raw(), mesh.size() * 3);
+    store_in_attribute_list(1, 2, mesh.raw_tex_coords(), mesh.tex_coords_size() * 2);
     unbind_vao();
 
     return {vao, mesh.indices_size()};
@@ -39,17 +40,20 @@ void Binder::store_in_attribute_list(uint32_t attribute, size_t size, float* dat
 
     glBindBuffer(GL_ARRAY_BUFFER, vbo);
     glBufferData(GL_ARRAY_BUFFER, data_size * sizeof(float), data, GL_STATIC_DRAW);
-    glVertexAttribPointer(attribute, size, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
+    glVertexAttribPointer(attribute, size, GL_FLOAT, GL_FALSE, size * sizeof(float), nullptr);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
 }
 
 void BindableMesh::bind() const {
     glBindVertexArray(m_vao);
     glEnableVertexAttribArray(0);
+    glEnableVertexAttribArray(1);
 }
 
 void BindableMesh::unbind() {
     glBindVertexArray(0);
     glDisableVertexAttribArray(0);
+    glDisableVertexAttribArray(1);
 }
 
 size_t BindableMesh::size() const {