Skip to content

Commit

Permalink
wip refactor: cleanup & modernize display implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxnii committed Sep 10, 2024
1 parent 0eed649 commit 6702f03
Show file tree
Hide file tree
Showing 28 changed files with 1,221 additions and 1,017 deletions.
9 changes: 9 additions & 0 deletions modules/core/src/main/kotlin/org/polyfrost/spice/Spice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import kotlinx.serialization.json.Json
import org.apache.logging.log4j.LogManager
import org.lwjgl.Version
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
Expand Down Expand Up @@ -73,6 +74,7 @@ object Spice {
Runtime.getRuntime().addShutdownHook(Thread {
if (options.needsSave) saveOptions()
})
GLFWErrorCallback.createPrint(System.err).set()

if (isMac()) GLFW_CHECK_THREAD0.set(false)
if (!glfwInit()) throw RuntimeException("Failed to initialize GLFW")
Expand All @@ -98,6 +100,13 @@ object Spice {
initializeDebugSections()
}

@JvmStatic
fun cleanup() {
logger.info("Terminating GLFW")

glfwTerminate()
}

@JvmStatic
fun saveOptions() {
if (!spiceDirectory.exists()) {
Expand Down
6 changes: 2 additions & 4 deletions modules/core/src/main/kotlin/org/polyfrost/spice/api/Mouse.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.polyfrost.spice.api

import org.lwjgl.input.Mouse as LwjglMouse

object Mouse {
@JvmStatic
fun isRawInputSupported(): Boolean = LwjglMouse.isRawInputSupported()
fun isRawInputSupported(): Boolean = true
@JvmStatic
fun setRawInput(raw: Boolean) = LwjglMouse.setRawInput(raw)
fun setRawInput(raw: Boolean) = false
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.polyfrost.spice.patcher.fixes

import org.lwjgl.LWJGLException
import org.polyfrost.spice.patcher.util.AudioHelper

@Suppress("unused")
Expand All @@ -10,7 +9,7 @@ object OpenAlFixes {
try {
AudioHelper.createContext(null, -1, 60, false)
} catch (ex: Throwable) {
throw LWJGLException(ex)
throw ex
}
}

Expand Down
11 changes: 0 additions & 11 deletions modules/lwjgl/src/main/kotlin/org/lwjgl/Sys.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
package org.lwjgl

import org.lwjgl.glfw.GLFWErrorCallback

@Suppress("unused")
object Sys {
private var initialized = false

@JvmStatic
fun getVersion(): String = Version.getVersion()

@JvmStatic
fun getTime(): Long = System.nanoTime()

@JvmStatic
fun getTimerResolution(): Long = 1000000000

@JvmStatic
fun initialize() {
if (initialized) return

GLFWErrorCallback.createThrow().set()
}
}
172 changes: 0 additions & 172 deletions modules/lwjgl/src/main/kotlin/org/lwjgl/input/Keyboard.kt

This file was deleted.

57 changes: 0 additions & 57 deletions modules/lwjgl/src/main/kotlin/org/lwjgl/input/Mouse.kt

This file was deleted.

Loading

0 comments on commit 6702f03

Please sign in to comment.