From 25e2a7ad4fd38674f0b59d83b51b941845ac6846 Mon Sep 17 00:00:00 2001 From: frank <420@shampoo.ooo> Date: Thu, 14 Oct 2021 02:55:39 -0400 Subject: [PATCH] use attributes object dimensions and type functions --- config.json | 2 +- lib/sb | 2 +- src/Pudding.cpp | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index fe596c0..4fd6d25 100644 --- a/config.json +++ b/config.json @@ -47,7 +47,7 @@ "enabled": true, "json-save": true, "json-save-directory": "local/scans", - "barcode": "", + "barcode": "045496591922", "capture-device": "/dev/video0" }, "api": diff --git a/lib/sb b/lib/sb index 64f6b76..3baaa76 160000 --- a/lib/sb +++ b/lib/sb @@ -1 +1 @@ -Subproject commit 64f6b765a76a5839dda44e5ca0dd153d17245aec +Subproject commit 3baaa7624e42880a47d55b2e659038019131ee02 diff --git a/src/Pudding.cpp b/src/Pudding.cpp index a2e1b89..1637c6a 100644 --- a/src/Pudding.cpp +++ b/src/Pudding.cpp @@ -210,23 +210,28 @@ void Pudding::load_gl_context() pudding_attributes["vertices"].size() + pudding_attributes["colors"].size(); glBufferData(GL_ARRAY_BUFFER, vbo_size, rectangle_attributes["position"], GL_STATIC_DRAW); /* specify the rectangle vertex attributes as consecutive 2D float coords */ - glVertexAttribPointer(rectangle_attributes["position"].index(), 2, GL_FLOAT, GL_FALSE, 0, nullptr); + glVertexAttribPointer(rectangle_attributes["position"].index(), rectangle_attributes["position"].dimensions(), + rectangle_attributes["position"].type(), GL_FALSE, 0, nullptr); /* copy rectangle UV data into the VBO, offset to after the vertex data, set up attributes */ GLintptr offset = rectangle_attributes["position"].size(); glBufferSubData(GL_ARRAY_BUFFER, offset, rectangle_attributes["uv"].size(), rectangle_attributes["uv"]); - glVertexAttribPointer(rectangle_attributes["uv"].index(), 2, GL_FLOAT, GL_FALSE, 0, reinterpret_cast(offset)); + glVertexAttribPointer(rectangle_attributes["uv"].index(), rectangle_attributes["uv"].dimensions(), + rectangle_attributes["uv"].type(), GL_FALSE, 0, reinterpret_cast(offset)); /* copy pudding vertices into VBO, offset to after the rectangle UV, and set up vertex attributes for 3D */ offset += rectangle_attributes["uv"].size(); glBufferSubData(GL_ARRAY_BUFFER, offset, pudding_attributes["vertices"].size(), pudding_attributes["vertices"]); - glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast(offset)); + glVertexAttribPointer(2, pudding_attributes["vertices"].dimensions(), pudding_attributes["vertices"].type(), + GL_FALSE, 0, reinterpret_cast(offset)); /* copy pudding color values into VBO, offset to after pudding vertices and set as 3D */ offset += pudding_attributes["vertices"].size(); glBufferSubData(GL_ARRAY_BUFFER, offset, pudding_attributes["colors"].size(), pudding_attributes["colors"]); - glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast(offset)); + glVertexAttribPointer(3, pudding_attributes["colors"].dimensions(), pudding_attributes["colors"].type(), + GL_FALSE, 0, reinterpret_cast(offset)); /* copy pudding UV values into VBO, offset to after pudding color vertices and set as 2D */ offset += pudding_attributes["colors"].size(); glBufferSubData(GL_ARRAY_BUFFER, offset, pudding_attributes["uv"].size(), pudding_attributes["uv"]); - glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, 0, reinterpret_cast(offset)); + glVertexAttribPointer(4, pudding_attributes["uv"].dimensions(), pudding_attributes["uv"].type(), + GL_FALSE, 0, reinterpret_cast(offset)); sb::Log::gl_errors("after loading attributes"); /* link shaders */ link_shader(flat_program);