From 1fe209d72a6b69ea8108b8203f7e876ce52ba703 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 23 Sep 2023 12:13:41 -0500 Subject: [PATCH] Add some additional logging to GLProxy around GLFW context creation --- .../core/render/glObject/GLProxy.java | 13 +++-- .../core/util/ReflectionUtil.java | 57 +++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 core/src/main/java/com/seibel/distanthorizons/core/util/ReflectionUtil.java 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 b4b674587..703437c8e 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 @@ -27,6 +27,7 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.enums.EGLProxyContext; import com.seibel.distanthorizons.core.logging.ConfigBasedLogger; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.util.ReflectionUtil; import com.seibel.distanthorizons.core.util.objects.GLMessage; import com.seibel.distanthorizons.core.util.objects.GLMessageOutputStream; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; @@ -167,14 +168,13 @@ public class GLProxy GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE); GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE); - LOGGER.info(this.minecraftGlCapabilities.toString()); - // create the Lod Builder context this.lodBuilderGlContext = GLFW.glfwCreateWindow(64, 48, "LOD Builder Window", 0L, this.minecraftGlContext); if (this.lodBuilderGlContext == 0) { - GL_LOGGER.error("ERROR: Failed to create GLFW context for OpenGL 3.2 with" - + " Forward Compat Core Profile! Your OS may have not been able to support it!"); + GL_LOGGER.error("ERROR: Failed to create LodBuilder GLFW context for OpenGL 3.2 with Forward compatible Core Profile! Your OS may have not been able to support it."); + GL_LOGGER.error("Minecraft GL Capabilities:\n [\n"+ReflectionUtil.getAllFieldValuesAsString(this.minecraftGlCapabilities)+"\n]\n"); + throw new UnsupportedOperationException("Forward Compat Core Profile 3.2 creation failure"); } // create the window @@ -197,8 +197,9 @@ public class GLProxy this.proxyWorkerGlContext = GLFW.glfwCreateWindow(64, 48, "LOD proxy worker Window", 0L, this.minecraftGlContext); if (this.proxyWorkerGlContext == 0) { - GL_LOGGER.error("ERROR: Failed to create GLFW context for OpenGL 3.2 with" - + " Forward Compat Core Profile! Your OS may have not been able to support it!"); + GL_LOGGER.error("ERROR: Failed to create GLProxy Worker GLFW context for OpenGL 3.2 with Forward compatible Core Profile! Your OS may have not been able to support it."); + GL_LOGGER.error("Minecraft GL Capabilities:\n [\n"+ReflectionUtil.getAllFieldValuesAsString(this.minecraftGlCapabilities)+"\n]\n"); + throw new UnsupportedOperationException("Forward Compat Core Profile 3.2 creation failure"); } // create the window diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/ReflectionUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/ReflectionUtil.java new file mode 100644 index 000000000..ed2acec93 --- /dev/null +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/ReflectionUtil.java @@ -0,0 +1,57 @@ +/* + * This file is part of the Distant Horizons mod + * licensed under the GNU LGPL v3 License. + * + * Copyright (C) 2020-2023 James Seibel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.seibel.distanthorizons.core.util; + +import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; +import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor; +import org.apache.logging.log4j.Logger; + +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Field; + +public class ReflectionUtil +{ + + public static String getAllFieldValuesAsString(Object obj) + { + StringBuilder stringBuilder = new StringBuilder(); + + Field[] fields = obj.getClass().getDeclaredFields(); + for (Field field : fields) + { + String fieldName = field.getName();; + String fieldStringValue; + try + { + field.setAccessible(true); + fieldStringValue = field.get(obj) + ""; + } + catch (Exception e) + { + fieldStringValue = "ERROR:[" + e.getMessage() + "]"; + } + + stringBuilder.append(fieldName+" - "+fieldStringValue+"\n"); + } + + return stringBuilder.toString(); + } + +}