Fixed block color & improve close

This commit is contained in:
TomTheFurry
2022-08-04 20:03:43 +08:00
parent 9a8145ff45
commit f6e5bdbd2f
5 changed files with 18 additions and 24 deletions
@@ -266,7 +266,7 @@ public class ColumnRenderSource implements LodRenderSource, IColumnDatatype {
}
private void cancelBuildBuffer() {
if (inBuildRenderBuffer != null) {
inBuildRenderBuffer.cancel(false);
inBuildRenderBuffer.cancel(true);
inBuildRenderBuffer = null;
}
}
@@ -167,8 +167,11 @@ public class ColumnRenderBuffer extends RenderBuffer {
}
}
private boolean closed = false;
@Override
public void close() {
if (closed) return;
closed = true;
GLProxy.getInstance().recordOpenGlCall(() -> {
for (GLVertexBuffer b : vbos) {
if (b == null) continue;
@@ -100,9 +100,10 @@ public class DhClientServerLevel implements IClientLevel, IServerLevel {
LOGGER.warn("Tried to call stopRenderer() on {} when renderer is already closed!", this);
return;
}
tree.close();
tree = null;
renderBufferHandler.close();
renderBufferHandler = null;
tree = null; //TODO Close the tree
generationQueue = null;
renderFileHandler.flushAndSave(); //Ignore the completion feature so that this action is async
renderFileHandler.close();
@@ -145,6 +146,7 @@ public class DhClientServerLevel implements IClientLevel, IServerLevel {
public void close() {
if (batchGenerator != null) batchGenerator.close();
if (renderer != null) renderer.close();
if (tree != null) tree.close();
if (renderBufferHandler != null) renderBufferHandler.close();
if (renderFileHandler != null) renderFileHandler.close();
dataFileHandler.close();
@@ -24,7 +24,7 @@ import org.apache.logging.log4j.Logger;
* -by loading from file
* -by adding data with the lodBuilder
*/
public class LodQuadTree {
public class LodQuadTree implements AutoCloseable {
/**
* Note: all config value should be via the class that extends this class, and
@@ -455,4 +455,14 @@ public class LodQuadTree {
}
return sb.toString();
}
@Override
public void close() {
for (MovableGridRingList<LodRenderSection> ringList : ringLists) {
ringList.forEach((section) -> {
if (section != null) section.dispose();
});
}
}
}
-21
View File
@@ -1,21 +0,0 @@
//module dhApi
//{
// requires org.apache.logging.log4j;
// requires org.lwjgl.opengl;
// requires java.datatransfer;
// requires com.google.common;
// requires java.desktop;
// requires org.lwjgl.glfw;
// requires com.formdev.flatlaf;
// requires json.simple; // not found
// requires core; // electronwill.nightconfig
// requires com.formdev.flatlaf.extras;
//
// // annotations
// requires org.jetbrains.annotations; // not found
// requires jsr305; // not found
//
//
// // Distant Horizons' API exports
// exports com.seibel.lod.core.api.external;
//}