diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/GPUInstancer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/GPUInstancer.java index a127b8e30..d3522ac81 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/GPUInstancer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/GPUInstancer.java @@ -69,7 +69,6 @@ public class GPUInstancer extends AbstractInstancer { vao = new GlVertexArray(); - // XXX Callback seems unnecessary. Remove and extract code to run after alloc call? model = modelAllocator.alloc(modelData, arenaModel -> { // XXX VAO is bound and not reset or restored vao.bind(); @@ -77,7 +76,7 @@ public class GPUInstancer extends AbstractInstancer { arenaModel.setupState(vao); }); - // XXX VAO is already guaranteed to be bound in model callback + // XXX VAO is bound and not reset or restored vao.bind(); vao.enableArrays(model.getAttributeCount() + instanceFormat.getAttributeCount()); diff --git a/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java b/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java index 37ba431b7..266f15489 100644 --- a/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java +++ b/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java @@ -79,6 +79,7 @@ public class QuadConverter { public void delete() { GL32.glDeleteBuffers(ebo); + this.cache.clear(); this.quadCapacity = 0; } diff --git a/src/main/java/com/jozufozu/flywheel/core/hardcoded/ModelPart.java b/src/main/java/com/jozufozu/flywheel/core/hardcoded/ModelPart.java index 67bdeb798..3b1ded7a6 100644 --- a/src/main/java/com/jozufozu/flywheel/core/hardcoded/ModelPart.java +++ b/src/main/java/com/jozufozu/flywheel/core/hardcoded/ModelPart.java @@ -51,4 +51,15 @@ public class ModelPart implements Model { public VertexList getReader() { return reader; } + + @Override + public void delete() { + if (reader instanceof AutoCloseable closeable) { + try { + closeable.close(); + } catch (Exception e) { + // + } + } + } } diff --git a/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java b/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java index 8c527bea6..fdfee66d2 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java @@ -47,4 +47,15 @@ public class BlockModel implements Model { public VertexList getReader() { return reader; } + + @Override + public void delete() { + if (reader instanceof AutoCloseable closeable) { + try { + closeable.close(); + } catch (Exception e) { + // + } + } + } } diff --git a/src/main/java/com/jozufozu/flywheel/core/model/Model.java b/src/main/java/com/jozufozu/flywheel/core/model/Model.java index e94d983ec..55066c90a 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/Model.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/Model.java @@ -62,6 +62,8 @@ public interface Model { .quads2Tris(vertexCount() / 4); } + void delete(); + /** * The size in bytes that this model's data takes up. */