From a282a4861255c463f49c9e5886b38ba76c476a7e Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 21 Jun 2021 02:41:50 +0200 Subject: [PATCH] Added delete function in VertexArray --- src/engine/Engine.java | 1 + src/engine/graphics/VertexArray.java | 11 +++++++++++ src/engine/object/ObjectGl.java | 4 ++++ src/gameplay/match/match.java | 6 +++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/engine/Engine.java b/src/engine/Engine.java index 999fab6..c6c3ceb 100644 --- a/src/engine/Engine.java +++ b/src/engine/Engine.java @@ -183,6 +183,7 @@ public class Engine { } public void remove_objectGl(ObjectGl obj) { + obj.delete(); this.objectsGl.remove(obj); } diff --git a/src/engine/graphics/VertexArray.java b/src/engine/graphics/VertexArray.java index a3626be..289119a 100644 --- a/src/engine/graphics/VertexArray.java +++ b/src/engine/graphics/VertexArray.java @@ -86,4 +86,15 @@ public class VertexArray { unbind(); } + /** + * Delete every buffers used + */ + public void delete(){ + glDeleteBuffers(VBO); + glDeleteBuffers(EBO); + glDeleteBuffers(CBO); + glDeleteBuffers(TBO); + glDeleteVertexArrays(VAO); + } + } diff --git a/src/engine/object/ObjectGl.java b/src/engine/object/ObjectGl.java index a4d7edb..5d1426b 100644 --- a/src/engine/object/ObjectGl.java +++ b/src/engine/object/ObjectGl.java @@ -291,4 +291,8 @@ public class ObjectGl { this.shader.disable(); } + public void delete(){ + this.vertexArray.delete(); + } + } diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 14e4b7d..037f5f4 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -398,9 +398,9 @@ public class match { timer = 99 - frameCount/60; timeStamp2 = System.currentTimeMillis(); -// while(timeStamp2-timeStamp1<(1000/(60 * slowFactor))) { -// timeStamp2 = System.currentTimeMillis(); -// } + while(timeStamp2-timeStamp1<(1000/(60 * slowFactor))) { + timeStamp2 = System.currentTimeMillis(); + } frameCounter++; if (System.currentTimeMillis() - timeStampFpsCounter >= 1000){