summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2023-02-04 11:13:29 -0800
committer3gg <3gg@shellblade.net>2023-02-04 11:13:29 -0800
commite9013f5cc95eb4cf0cb621e130a9024382b5b041 (patch)
treeff5234d812a6defca223fe5d5d5685558a4744d0
parent4eee2853cb38892283fffc939b8f2d4e540c0d30 (diff)
Simplify Buffer implementation.
-rw-r--r--gfx/src/render/buffer.c27
1 files 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) {
16} 16}
17 17
18bool gfx_init_buffer_2d(Buffer* buffer, const vec2* verts, size_t count) { 18bool gfx_init_buffer_2d(Buffer* buffer, const vec2* verts, size_t count) {
19 assert(buffer); 19 return gfx_init_buffer(buffer, (const void*)verts, count * sizeof(vec2));
20 buffer->size_bytes = count * sizeof(vec2);
21 glGenBuffers(1, &buffer->vbo);
22 glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
23 glBufferData(GL_ARRAY_BUFFER, sizeof(vec2) * count, verts, GL_STATIC_DRAW);
24 glBindBuffer(GL_ARRAY_BUFFER, 0);
25 ASSERT_GL;
26 return true;
27} 20}
28 21
29bool gfx_init_buffer_3d(Buffer* buffer, const vec3* verts, size_t count) { 22bool gfx_init_buffer_3d(Buffer* buffer, const vec3* verts, size_t count) {
30 assert(buffer); 23 return gfx_init_buffer(buffer, (const void*)verts, count * sizeof(vec3));
31 buffer->size_bytes = count * sizeof(vec3);
32 glGenBuffers(1, &buffer->vbo);
33 glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
34 glBufferData(GL_ARRAY_BUFFER, sizeof(vec3) * count, verts, GL_STATIC_DRAW);
35 glBindBuffer(GL_ARRAY_BUFFER, 0);
36 ASSERT_GL;
37 return true;
38} 24}
39 25
40bool gfx_init_buffer_4d(Buffer* buffer, const vec4* verts, size_t count) { 26bool gfx_init_buffer_4d(Buffer* buffer, const vec4* verts, size_t count) {
41 assert(buffer); 27 return gfx_init_buffer(buffer, (const void*)verts, count * sizeof(vec4));
42 buffer->size_bytes = count * sizeof(vec4);
43 glGenBuffers(1, &buffer->vbo);
44 glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
45 glBufferData(GL_ARRAY_BUFFER, sizeof(vec4) * count, verts, GL_STATIC_DRAW);
46 glBindBuffer(GL_ARRAY_BUFFER, 0);
47 ASSERT_GL;
48 return true;
49} 28}
50 29
51void gfx_del_buffer(Buffer* buffer) { 30void gfx_del_buffer(Buffer* buffer) {