remove unneeded memset and update for vbo_t

main
Brett 2023-12-28 12:21:24 -05:00
parent f9cd25f00e
commit bc14d16db2
2 changed files with 10 additions and 11 deletions

View File

@ -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();
};
/**

View File

@ -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<GLuint*>(data_))
if (std::holds_alternative<vbo_t*>(data_))
{
auto* ptr = std::get<GLuint*>(data_);
auto* ptr = std::get<vbo_t*>(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);
}