mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
fix window centering on start
This commit is contained in:
parent
8fa3a44fb9
commit
02a93a9682
@ -29,6 +29,7 @@ import org.lwjgl.glfw.GLFW.*
|
|||||||
import org.lwjgl.glfw.GLFWErrorCallback
|
import org.lwjgl.glfw.GLFWErrorCallback
|
||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
|
|
||||||
|
|
||||||
class GLFWWindow(
|
class GLFWWindow(
|
||||||
private val eventMaster: EventMaster,
|
private val eventMaster: EventMaster,
|
||||||
) : BaseWindow {
|
) : BaseWindow {
|
||||||
@ -43,7 +44,7 @@ class GLFWWindow(
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _size = DEFAULT_WINDOW_SIZE
|
private var _size = Vec2i(DEFAULT_WINDOW_SIZE)
|
||||||
|
|
||||||
override var size: Vec2i
|
override var size: Vec2i
|
||||||
get() = _size
|
get() = _size
|
||||||
@ -132,13 +133,14 @@ class GLFWWindow(
|
|||||||
throw RuntimeException("Failed to create the GLFW window")
|
throw RuntimeException("Failed to create the GLFW window")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(window)
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
|
||||||
val videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor())!!
|
val videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor())!!
|
||||||
|
|
||||||
glfwSetWindowPos(window, (videoMode.width() - size.x) / 2, (videoMode.height() - size.y) / 2)
|
glfwSetWindowPos(window, (videoMode.width() - size.x) / 2, (videoMode.height() - size.y) / 2)
|
||||||
|
|
||||||
glfwMakeContextCurrent(window)
|
|
||||||
|
|
||||||
|
|
||||||
glfwSetKeyCallback(window, this::keyInput)
|
glfwSetKeyCallback(window, this::keyInput)
|
||||||
glfwSetMouseButtonCallback(window, this::mouseKeyInput)
|
glfwSetMouseButtonCallback(window, this::mouseKeyInput)
|
||||||
@ -151,8 +153,6 @@ class GLFWWindow(
|
|||||||
glfwSetWindowCloseCallback(window, this::onClose)
|
glfwSetWindowCloseCallback(window, this::onClose)
|
||||||
glfwSetWindowFocusCallback(window, this::onFocusChange)
|
glfwSetWindowFocusCallback(window, this::onFocusChange)
|
||||||
glfwSetWindowIconifyCallback(window, this::onIconify)
|
glfwSetWindowIconifyCallback(window, this::onIconify)
|
||||||
|
|
||||||
super.init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun destroy() {
|
override fun destroy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user