From bc14d16db21505461f003cd18550b964648c37d1 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 28 Dec 2023 12:21:24 -0500 Subject: [PATCH] remove unneeded memset and update for vbo_t --- include/blt/gfx/model.h | 4 ++-- src/blt/gfx/model.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/blt/gfx/model.h b/include/blt/gfx/model.h index 1a7c3cd..e4f2962 100644 --- a/include/blt/gfx/model.h +++ b/include/blt/gfx/model.h @@ -41,7 +41,7 @@ namespace blt::gfx GLuint bufferID_ = 0; GLsizeiptr size_ = 0; - vbo_t(); + void create(); void bind(GLint buffer_type = GL_ARRAY_BUFFER) const; @@ -51,7 +51,7 @@ namespace blt::gfx void update(GLsizeiptr size, void* data, GLint buffer_type = GL_ARRAY_BUFFER, GLint memory_type = GL_STATIC_DRAW); - ~vbo_t(); + void destroy(); }; /** diff --git a/src/blt/gfx/model.cpp b/src/blt/gfx/model.cpp index d3cfb0d..d53f53b 100644 --- a/src/blt/gfx/model.cpp +++ b/src/blt/gfx/model.cpp @@ -24,12 +24,11 @@ namespace blt::gfx { size_t next_size = blt::mem::next_byte_allocation(size_); - auto* new_data = new GLuint[next_size]; - std::memset(new_data, 0, next_size); + auto* new_data = new vbo_t[next_size]; - if (std::holds_alternative(data_)) + if (std::holds_alternative(data_)) { - auto* ptr = std::get(data_); + auto* ptr = std::get(data_); std::memcpy(new_data, ptr, size_); delete[] ptr; } else { @@ -51,12 +50,12 @@ namespace blt::gfx * vbo_t * ----------------------------------- */ - vbo_t::vbo_t() + void vbo_t::create() { glGenBuffers(1, &bufferID_); } - vbo_t::~vbo_t() + void vbo_t::destroy() { glDeleteBuffers(1, &bufferID_); } @@ -76,12 +75,12 @@ namespace blt::gfx size_ = size; } - void basic_vertex_array::vbo_t::sub_update(GLsizeiptr offset, GLsizeiptr size, void* data, GLint buffer_type) + void vbo_t::sub_update(GLsizeiptr offset, GLsizeiptr size, void* data, GLint buffer_type) { glBufferSubData(buffer_type, offset, size, data); } - void basic_vertex_array::vbo_t::bind(GLint buffer_type) const + void vbo_t::bind(GLint buffer_type) const { glBindBuffer(buffer_type, bufferID_); } @@ -92,7 +91,7 @@ namespace blt::gfx * ---------------------------- */ - blt::gfx::basic_vertex_array::basic_vertex_array() + basic_vertex_array::basic_vertex_array(): vaoID(0) { glGenVertexArrays(1, &vaoID); }