From e9013f5cc95eb4cf0cb621e130a9024382b5b041 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 4 Feb 2023 11:13:29 -0800 Subject: Simplify Buffer implementation. --- gfx/src/render/buffer.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/gfx/src/render/buffer.c b/gfx/src/render/buffer.c index d027e8b..3536dcb 100644 --- a/gfx/src/render/buffer.c +++ b/gfx/src/render/buffer.c @@ -16,36 +16,15 @@ bool gfx_init_buffer(Buffer* buffer, const void* data, size_t size_bytes) { } bool gfx_init_buffer_2d(Buffer* buffer, const vec2* verts, size_t count) { - assert(buffer); - buffer->size_bytes = count * sizeof(vec2); - glGenBuffers(1, &buffer->vbo); - glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(vec2) * count, verts, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - ASSERT_GL; - return true; + return gfx_init_buffer(buffer, (const void*)verts, count * sizeof(vec2)); } bool gfx_init_buffer_3d(Buffer* buffer, const vec3* verts, size_t count) { - assert(buffer); - buffer->size_bytes = count * sizeof(vec3); - glGenBuffers(1, &buffer->vbo); - glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(vec3) * count, verts, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - ASSERT_GL; - return true; + return gfx_init_buffer(buffer, (const void*)verts, count * sizeof(vec3)); } bool gfx_init_buffer_4d(Buffer* buffer, const vec4* verts, size_t count) { - assert(buffer); - buffer->size_bytes = count * sizeof(vec4); - glGenBuffers(1, &buffer->vbo); - glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(vec4) * count, verts, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - ASSERT_GL; - return true; + return gfx_init_buffer(buffer, (const void*)verts, count * sizeof(vec4)); } void gfx_del_buffer(Buffer* buffer) { -- cgit v1.2.3