Add more graphics debug options

This commit is contained in:
Fingercomp 2023-06-08 14:27:19 +07:00
parent 5146a9186e
commit 09454d99ab
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37
3 changed files with 22 additions and 3 deletions

View File

@ -22,6 +22,8 @@ class Settings(val config: Config) extends SettingsData {
windowPosition = config.getInt2D("ocelot.window.position")
windowValidatePosition = config.getBooleanOrElse("ocelot.window.validatePosition", default = true)
windowFullscreen = config.getBooleanOrElse("ocelot.window.fullscreen", default = false)
disableVsync = config.getBooleanOrElse("ocelot.window.disableVsync", default = false)
debugLwjgl = config.getBooleanOrElse("ocelot.window.debugLwjgl", default = false)
// Windows uses life-hack when it sets position to (-8,-8) for maximized windows to hide the frame.
// (https://devblogs.microsoft.com/oldnewthing/20150304-00/?p=44543)
@ -135,6 +137,8 @@ object Settings extends Logging {
.withValuePreserveOrigin("ocelot.window.validatePosition", settings.windowValidatePosition)
.withValue("ocelot.window.size", settings.windowSize)
.withValuePreserveOrigin("ocelot.window.fullscreen", settings.windowFullscreen)
.withValuePreserveOrigin("ocelot.window.disableVsync", settings.disableVsync)
.withValuePreserveOrigin("ocelot.window.debugLwjgl", settings.debugLwjgl)
.withValue("ocelot.workspace.recent", settings.recentWorkspace)
.withValuePreserveOrigin("ocelot.workspace.stickyWindows", settings.stickyWindows)
.withValuePreserveOrigin("ocelot.workspace.saveOnExit", settings.saveOnExit)

View File

@ -144,14 +144,22 @@ object UiHandler extends Logging {
windowTitle = "Ocelot Desktop v" + BuildInfo.version
loadIcons()
Display.setVSyncEnabled(true)
if (!Settings.get.disableVsync) {
logger.info("VSync enabled")
Display.setVSyncEnabled(true)
} else {
logger.info("VSync disabled (via config)")
}
Display.create()
KeyEvents.init()
MouseEvents.init()
logger.info(s"Created window with ${root.size}")
logger.info(s"Created window: ${Display.getWidth}×${Display.getHeight} (at ${Display.getX}, ${Display.getY})")
logger.info(s"OpenGL vendor: ${GL11.glGetString(GL11.GL_VENDOR)}")
logger.info(s"OpenGL renderer: ${GL11.glGetString(GL11.GL_RENDERER)}")
logger.info(s"OpenGL version: ${GL11.glGetString(GL11.GL_VERSION)}")
Spritesheet.load()
graphics = new Graphics(scalingFactor)
@ -210,6 +218,11 @@ object UiHandler extends Logging {
}
System.setProperty("org.lwjgl.librarypath", nativeLibrariesDir)
if (Settings.get.debugLwjgl) {
logger.info("Enabling LWJGL debug mode")
System.setProperty("org.lwjgl.util.Debug", true.toString)
}
}
private def loadIcons(): Unit = {

View File

@ -25,6 +25,8 @@ class SettingsData {
var windowPosition: Int2D = new Int2D()
var windowValidatePosition: Boolean = true
var windowFullscreen: Boolean = false
var disableVsync: Boolean = false
var debugLwjgl: Boolean = false
var recentWorkspace: Option[String] = None
@ -32,7 +34,7 @@ class SettingsData {
var saveOnExit: Boolean = true
var openLastWorkspace: Boolean = true
private val mirror = scala.reflect.runtime.universe.runtimeMirror(getClass.getClassLoader).reflect(this)
private val mirror = ru.runtimeMirror(getClass.getClassLoader).reflect(this)
def updateWith(data: SettingsData): Unit = {
for (fieldSym <- Fields) {