Handle a few rendering setup edge cases

This commit is contained in:
James Seibel
2025-10-02 07:07:22 -05:00
parent 12a885aa6e
commit be87c79b1b
2 changed files with 12 additions and 7 deletions
@@ -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)
{
@@ -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!");