summaryrefslogtreecommitdiff
path: root/src/renderer/render.c
diff options
context:
space:
mode:
authoromnisci3nce <17525998+omnisci3nce@users.noreply.github.com>2024-04-04 22:53:13 +1100
committeromnisci3nce <17525998+omnisci3nce@users.noreply.github.com>2024-04-04 22:53:13 +1100
commit9baff5661f2ba8b57e1b0794e490e239b7ef80ca (patch)
tree11ae178c14f59c4fcb380cdcc1bf38d065c9eee2 /src/renderer/render.c
parentaf97c4330a27a92d2362e30b70990e3aa5c9954a (diff)
loading animation data - step 1
Diffstat (limited to 'src/renderer/render.c')
-rw-r--r--src/renderer/render.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/renderer/render.c b/src/renderer/render.c
index 2993225..2f5e553 100644
--- a/src/renderer/render.c
+++ b/src/renderer/render.c
@@ -1,3 +1,4 @@
+#include "mem.h"
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
@@ -88,6 +89,21 @@ void default_material_init() {
texture_data_upload(&DEFAULT_MATERIAL.specular_texture);
}
+void model_destroy(model* model) {
+ arena_free_all(&model->animation_data_arena);
+ arena_free_storage(&model->animation_data_arena);
+ mesh_darray_free(model->meshes);
+ material_darray_free(model->materials);
+ if (model->is_uploaded) {
+ // Delete gpu buffer data
+ for (u32 i = 0; i < mesh_darray_len(model->meshes); i++) {
+ // FIXME: dont leak Opengl
+ glDeleteBuffers(1, &model->meshes->data[i].vbo);
+ glDeleteVertexArrays(1, &model->meshes->data[i].vao);
+ }
+ }
+}
+
void draw_model(renderer* ren, camera* camera, model* model, transform tf, scene* scene) {
// TRACE("Drawing model: %s", model->name);
mat4 view;