From 1bc99f522479c084892f9a8ce2b4185bd864e779 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Mon, 11 Jan 2021 11:15:45 -0800 Subject: [PATCH] maybe magically fix all crashes? --- .../utility/render/ContraptionLighter.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/render/ContraptionLighter.java b/src/main/java/com/simibubi/create/foundation/utility/render/ContraptionLighter.java index 083924da3..e7f65e52a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/render/ContraptionLighter.java +++ b/src/main/java/com/simibubi/create/foundation/utility/render/ContraptionLighter.java @@ -23,7 +23,7 @@ public class ContraptionLighter { private final int sizeY; private final int sizeZ; - private ByteBuffer lightVolume; + private SafeDirectBuffer lightVolume; private boolean dirty; @@ -45,7 +45,7 @@ public class ContraptionLighter { sizeY = nextPowerOf2(maxY - minY); sizeZ = nextPowerOf2(maxZ - minZ); - lightVolume = GLAllocation.createDirectByteBuffer(sizeX * sizeY * sizeZ * 2); + lightVolume = new SafeDirectBuffer(sizeX * sizeY * sizeZ * 2); update(contraption); } @@ -83,7 +83,11 @@ public class ContraptionLighter { RenderWork.enqueue(() -> { GL15.glDeleteTextures(texture); texture = 0; - MemoryUtil.memFree(lightVolume); + try { + lightVolume.close(); + } catch (Exception e) { + e.printStackTrace(); + } lightVolume = null; }); } @@ -140,7 +144,7 @@ public class ContraptionLighter { GL11.glTexParameteri(GL13.GL_TEXTURE_3D, GL13.GL_TEXTURE_WRAP_R, GL13.GL_CLAMP); GL11.glTexParameteri(GL13.GL_TEXTURE_3D, GL13.GL_TEXTURE_WRAP_T, GL13.GL_CLAMP); if (dirty) { - GL12.glTexImage3D(GL12.GL_TEXTURE_3D, 0, GL40.GL_RG8, sizeX, sizeY, sizeZ, 0, GL40.GL_RG, GL40.GL_UNSIGNED_BYTE, lightVolume); + GL12.glTexImage3D(GL12.GL_TEXTURE_3D, 0, GL40.GL_RG8, sizeX, sizeY, sizeZ, 0, GL40.GL_RG, GL40.GL_UNSIGNED_BYTE, lightVolume.getBacking()); dirty = false; } }