diff options
author | 3gg <3gg@shellblade.net> | 2023-02-04 11:13:29 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-02-04 11:13:29 -0800 |
commit | e9013f5cc95eb4cf0cb621e130a9024382b5b041 (patch) | |
tree | ff5234d812a6defca223fe5d5d5685558a4744d0 | |
parent | 4eee2853cb38892283fffc939b8f2d4e540c0d30 (diff) |
Simplify Buffer implementation.
-rw-r--r-- | gfx/src/render/buffer.c | 27 |
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 | ||
18 | bool gfx_init_buffer_2d(Buffer* buffer, const vec2* verts, size_t count) { | 18 | bool 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 | ||
29 | bool gfx_init_buffer_3d(Buffer* buffer, const vec3* verts, size_t count) { | 22 | bool 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 | ||
40 | bool gfx_init_buffer_4d(Buffer* buffer, const vec4* verts, size_t count) { | 26 | bool 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 | ||
51 | void gfx_del_buffer(Buffer* buffer) { | 30 | void gfx_del_buffer(Buffer* buffer) { |