From 131f06b012d110621ba0f2e8d773dd675c23db3c Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 24 Oct 2020 19:39:28 +0300 Subject: [PATCH] Support binding gfx::mesh --- libs/gfx/include/psemek/gfx/mesh.hpp | 2 ++ libs/gfx/source/mesh.cpp | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/gfx/include/psemek/gfx/mesh.hpp b/libs/gfx/include/psemek/gfx/mesh.hpp index f8ced8c5..c1e21f8d 100644 --- a/libs/gfx/include/psemek/gfx/mesh.hpp +++ b/libs/gfx/include/psemek/gfx/mesh.hpp @@ -115,6 +115,8 @@ namespace psemek::gfx mesh(mesh const &) = delete; mesh & operator = (mesh const &) = delete; + void bind() const; + void setup(attribs_description const & attribs); template diff --git a/libs/gfx/source/mesh.cpp b/libs/gfx/source/mesh.cpp index 99387889..4fe3dd34 100644 --- a/libs/gfx/source/mesh.cpp +++ b/libs/gfx/source/mesh.cpp @@ -29,11 +29,16 @@ namespace psemek::gfx return *this; } + void mesh::bind() const + { + array_.bind(); + } + void mesh::setup(attribs_description const & attribs) { assert(!attribs.attribs.empty()); - array_.bind(); + bind(); for (std::size_t i = 0; i < info_.max_attribute_index_; ++i) gl::DisableVertexAttribArray(i); @@ -108,7 +113,7 @@ namespace psemek::gfx if (count != 0 && instance_count != 0) { - array_.bind(); + bind(); gl::DrawElementsInstanced(primitive_type(), count, index_type(), reinterpret_cast(detail::index_size(index_type()) * first), instance_count); } } @@ -116,7 +121,7 @@ namespace psemek::gfx { if (count != 0) { - array_.bind(); + bind(); gl::DrawElements(primitive_type(), count, index_type(), reinterpret_cast(detail::index_size(index_type()) * first)); } } @@ -131,7 +136,7 @@ namespace psemek::gfx if (count != 0 && instance_count != 0) { - array_.bind(); + bind(); gl::DrawArraysInstanced(primitive_type(), first, count, instance_count); } } @@ -139,7 +144,7 @@ namespace psemek::gfx { if (count != 0) { - array_.bind(); + bind(); gl::DrawArrays(primitive_type(), first, count); } }