diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index b483d5e1f..63e56fc79 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -1015,9 +1015,23 @@ public class Config public static class OpenGl { public static ConfigEntry overrideVanillaGLLogger = new ConfigEntry.Builder() - .set(ModInfo.IS_DEV_BUILD) + .set(true) .comment("" - + "Requires a reboot to change. \n" + + "Defines how OpenGL errors are handled. \n " + + "Requires rebooting Minecraft to change. \n" + + "Will catch OpenGL errors thrown by other mods. \n" + + "") + .build(); + + public static ConfigEntry onlyLogGlErrorsOnce = new ConfigEntry.Builder() + .set(true) + .comment("" + + "If true each Open GL error will only be logged once. \n" + + "Enabling this may cause some error logs to be missed. \n" + + "Does nothing if overrideVanillaGLLogger is set to false. \n" + + " \n" + + "Generally this can be kept as 'true' to prevent log spam. \n" + + "However, Please set this to 'false' if a developer needs your log to debug a GL issue. \n" + "") .build(); 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 7cc262839..5efae5050 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 @@ -38,6 +38,10 @@ import org.lwjgl.opengl.GLCapabilities; 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; /** @@ -52,6 +56,10 @@ public class GLProxy public static final ConfigBasedLogger GL_LOGGER = new ConfigBasedLogger(LogManager.getLogger(GLProxy.class), () -> Config.Common.Logging.logRendererGLEvent.get()); + public static final Set LOGGED_GL_MESSAGES = Collections.newSetFromMap(new ConcurrentHashMap()); + + + private static GLProxy instance = null; @@ -279,8 +287,19 @@ public class GLProxy } + + boolean onlyLogOnce = Config.Client.Advanced.Debugging.OpenGl.onlyLogGlErrorsOnce.get(); + String errorMessage = "GL ERROR [" + msg.id + "] from [" + msg.source + "]: [" + msg.message + "]"+(onlyLogOnce ? " this message will only be logged once" : "")+"."; + if (onlyLogOnce + && !LOGGED_GL_MESSAGES.add(errorMessage)) + { + // this message has already been logged + return; + } + + // create an exception so we get a stacktrace of where the message was triggered from - RuntimeException exception = new RuntimeException("GL ERROR [" + msg.id + "] from [" + msg.source + "]: [" + msg.message + "]."); + RuntimeException exception = new RuntimeException(errorMessage); if (msg.type == EGLMessageType.ERROR || msg.type == EGLMessageType.UNDEFINED_BEHAVIOR) { diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index 940741340..0e03caf3d 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -477,7 +477,11 @@ "distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger": "Override Vanilla GL Logger", "distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger.@tooltip": - "Defines how OpenGL errors are handled. \n Requires rebooting Minecraft to apply. \nMay incorrectly catch OpenGL errors thrown by other mods.", + "Defines how OpenGL errors are handled. \nRequires rebooting Minecraft to change. \nWill catch OpenGL errors thrown by other mods.", + "distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce": + "Only Log GL Errors Once", + "distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce.@tooltip": + "If true each Open GL error will only be logged once. \nTEnabling this may cause some error logs to be missed. \nDoes nothing if overrideVanillaGLLogger is set to false. \n\nGenerally this can be kept as 'true' to prevent log spam. \nHowever, Please set this to 'false' if a developer needs your log to debug a GL issue. \n", "distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode": "OpenGL Error Handling Mode", "distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode.@tooltip":