From 0b48323783a37059c9af13a5bda403465b1fea14 Mon Sep 17 00:00:00 2001 From: mattkae Date: Thu, 13 Oct 2022 18:50:52 -0400 Subject: Fixing bug where deallocation wasn't happening --- themes/Renderer2d.cpp | 5 ++++- themes/Snowflake.cpp | 2 ++ themes/SummerTheme.cpp | 2 +- themes/dist/output.wasm | Bin 135264 -> 135640 bytes 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/themes/Renderer2d.cpp b/themes/Renderer2d.cpp index 606b7fc..c303e83 100644 --- a/themes/Renderer2d.cpp +++ b/themes/Renderer2d.cpp @@ -123,7 +123,10 @@ void Mesh2D::render(Renderer2d* renderer, GLenum drawType) { void Mesh2D::unload() { glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &vbo); - if (ebo) { + if (ebo != 0) { glDeleteBuffers(1, &ebo); + ebo = 0; } + vao = 0; + vbo = 0; } diff --git a/themes/Snowflake.cpp b/themes/Snowflake.cpp index 9a8abde..d5373f4 100644 --- a/themes/Snowflake.cpp +++ b/themes/Snowflake.cpp @@ -179,6 +179,8 @@ void SnowflakeParticleRenderer::render(Renderer2d* renderer) { void SnowflakeParticleRenderer::unload() { glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &vbo); + vao = 0; + vbo = 0; vertices.deallocate(); delete [] updateData; } diff --git a/themes/SummerTheme.cpp b/themes/SummerTheme.cpp index b23cc71..20bb310 100644 --- a/themes/SummerTheme.cpp +++ b/themes/SummerTheme.cpp @@ -23,7 +23,6 @@ void SummerTheme::unload() { sun.unload(); } - void Sun::load(Renderer2d* renderer) { matte::List vertices; matte::List indices; @@ -49,6 +48,7 @@ void Sun::load(Renderer2d* renderer) { mesh.load(&vertices.data[0], vertices.numElements, &indices.data[0], indices.numElements, renderer); mesh.model = Mat4x4().translateByVec2(Vector2(renderer->context->width / 2.f, renderer->context->height / 2.f)); vertices.deallocate(); + indices.deallocate(); } void Sun::update(f32 dtSeconds) { diff --git a/themes/dist/output.wasm b/themes/dist/output.wasm index ced481d..1d42a88 100755 Binary files a/themes/dist/output.wasm and b/themes/dist/output.wasm differ -- cgit v1.2.1