diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java index 44717187f..be0061b8a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/GLProxy.java @@ -29,7 +29,6 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.util.objects.GLMessages.*; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.coreapi.ModInfo; -import com.seibel.distanthorizons.coreapi.util.StringUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.glfw.GLFW; @@ -40,7 +39,6 @@ import org.lwjgl.opengl.GLUtil; import java.io.PrintStream; import java.util.Collections; -import java.util.HashSet; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -212,7 +210,8 @@ public class GLProxy //=========// public static boolean hasInstance() { return instance != null; } - public static GLProxy getInstance() + /** @throws IllegalStateException if the Proxy hasn't been created yet and this is called outside the render thread */ + public static GLProxy getInstance() throws IllegalStateException { if (instance == null) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java index d3deefa67..b6de99518 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java @@ -106,7 +106,7 @@ public class LodRenderer // The shader program private IDhApiShaderProgram lodRenderProgram = null; public QuadElementBuffer quadIBO = null; - public boolean isSetupComplete = false; + private boolean isSetupComplete = false; // frameBuffer and texture ID's for this renderer private IDhApiFramebuffer framebuffer; @@ -252,6 +252,11 @@ public class LodRenderer ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderSetupEvent.class, renderEventParam); this.setupGLStateAndRenderObjects(profiler, renderEventParam, renderingFirstPass); + if (!this.isSetupComplete) + { + // this shouldn't normally happen, but just in case + return; + } lightmap.bind(); this.quadIBO.bind(); @@ -633,7 +638,7 @@ public class LodRenderer EVENT_LOGGER.warn("Renderer setup called but it has already completed setup!"); return; } - if (GLProxy.getInstance() == null) + if (!GLProxy.hasInstance()) { // shouldn't normally happen, but just in case EVENT_LOGGER.warn("Renderer setup called but GLProxy has not yet been setup!"); @@ -646,7 +651,6 @@ public class LodRenderer EVENT_LOGGER.info("Setting up renderer"); - this.isSetupComplete = true; this.lodRenderProgram = new DhTerrainShaderProgram(); this.quadIBO = new QuadElementBuffer(); @@ -675,9 +679,11 @@ public class LodRenderer { // This generally means something wasn't bound, IE missing either the color or depth texture EVENT_LOGGER.warn("FrameBuffer ["+this.framebuffer.getId()+"] isn't complete."); + return; } + this.isSetupComplete = true; EVENT_LOGGER.info("Renderer setup complete"); } finally @@ -771,7 +777,7 @@ public class LodRenderer */ private void cleanup() { - if (GLProxy.getInstance() == null) + if (!GLProxy.hasInstance()) { // shouldn't normally happen, but just in case EVENT_LOGGER.warn("Renderer Cleanup called but the GLProxy has never been initialized!");