diff --git a/src/main/kotlin/wtf/zani/spice/Spice.kt b/src/main/kotlin/wtf/zani/spice/Spice.kt index 4f996d8..a0ac165 100644 --- a/src/main/kotlin/wtf/zani/spice/Spice.kt +++ b/src/main/kotlin/wtf/zani/spice/Spice.kt @@ -8,12 +8,14 @@ import org.lwjgl.glfw.GLFW.* import org.lwjgl.glfw.GLFWErrorCallback import org.lwjgl.openal.AL10.AL_VERSION import org.lwjgl.openal.AL10.alGetString +import org.lwjgl.system.Configuration.GLFW_CHECK_THREAD0 import org.lwjgl.system.MemoryStack import wtf.zani.spice.debug.DebugHelper import wtf.zani.spice.debug.DebugSection import wtf.zani.spice.input.inputSection import wtf.zani.spice.platform.Platform import wtf.zani.spice.util.getResource +import wtf.zani.spice.util.isMac import wtf.zani.spice.util.isOptifineLoaded import kotlin.io.path.* @@ -53,9 +55,11 @@ object Spice { @JvmStatic internal fun initialize() { Runtime.getRuntime().addShutdownHook(Thread { - if (options.needsSave) saveOptions() + if (this::options.isInitialized && options.needsSave) saveOptions() }) + if (isMac()) GLFW_CHECK_THREAD0.set(false) + GLFWErrorCallback.createPrint(System.err).set() if (!glfwInit()) throw IllegalStateException("Failed to initialize GLFW") diff --git a/src/main/kotlin/wtf/zani/spice/util/SystemUtil.kt b/src/main/kotlin/wtf/zani/spice/util/SystemUtil.kt new file mode 100644 index 0000000..aaf4eb4 --- /dev/null +++ b/src/main/kotlin/wtf/zani/spice/util/SystemUtil.kt @@ -0,0 +1,7 @@ +package wtf.zani.spice.util + +import org.lwjgl.system.Platform +import org.lwjgl.system.Platform.MACOSX + +fun isMac(): Boolean = + Platform.get() == MACOSX