summaryrefslogtreecommitdiff
path: root/src/rendering.cc
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-02-11 23:26:31 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-02-11 23:26:31 +0100
commit8536bcc71498c9109ef4254760edc4cd70ddcccd (patch)
treebafe2d4b267a3f3fb0753dee0c852b28bcfb619e /src/rendering.cc
parent9a90a8f6a6df2603c510f90ec351edf5aca4f8f6 (diff)
working on vao
Diffstat (limited to 'src/rendering.cc')
-rw-r--r--src/rendering.cc62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/rendering.cc b/src/rendering.cc
index 65a89b1..06a40c7 100644
--- a/src/rendering.cc
+++ b/src/rendering.cc
@@ -153,4 +153,64 @@ bool wayc_atlas_packer_allocate(struct atlas_packer_s* packer, u32 width,
packer->row_height = wayc_max(packer->row_height, height);
return true;
-} \ No newline at end of file
+}
+
+bool wayc_vbo_init(vbo_t* vbo, usize size) {
+ wayc_notnull(vbo);
+
+ glCreateBuffers(1, vbo);
+ if (*vbo == 0) return false;
+
+ glNamedBufferStorage(*vbo, size, NULL, GL_DYNAMIC_STORAGE_BIT);
+ return true;
+}
+
+bool wayc_vbo_upload(vbo_t vbo, usize offset, usize size, const u8* data) {
+ wayc_notnull(data);
+
+ glNamedBufferSubData(vbo, offset, size, data); // TODO: add error checking
+ return true;
+}
+
+void wayc_vbo_use(vbo_t vbo) { glBindBuffer(GL_ARRAY_BUFFER, vbo); }
+
+void wayc_vbo_deinit(vbo_t* vbo) {
+ wayc_notnull(vbo);
+ glDeleteBuffers(1, vbo);
+}
+
+bool wayc_ebo_init(ebo_t* ebo, usize size) {
+ wayc_notnull(ebo);
+
+ glCreateBuffers(1, ebo);
+ if (*ebo == 0) return false;
+
+ glNamedBufferStorage(*ebo, size, NULL, GL_DYNAMIC_STORAGE_BIT);
+ return true;
+}
+
+bool wayc_ebo_upload(ebo_t ebo, usize offset, usize size, const u8* data) {
+ wayc_notnull(data);
+
+ glNamedBufferSubData(ebo, offset, size, data);
+ return true;
+}
+
+void wayc_ebo_use(ebo_t ebo) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); }
+
+void wayc_ebo_deinit(ebo_t* ebo) {
+ wayc_notnull(ebo);
+ glDeleteBuffers(1, ebo);
+}
+
+bool wayc_vao_init(vao_t* vao, vbo_t vbo, ebo_t ebo, const vao_attr_s* attrs,
+ u32 attr_count) {
+ wayc_notnull(vao);
+ wayc_notnull(attrs);
+
+ glCreateVertexArrays(1, vao);
+ if (*vao == 0) return false;
+}
+
+void wayc_vao_use(vao_t vao);
+void wayc_vao_deinit(vao_t* vao); \ No newline at end of file