mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 19:35:00 -04:00
rendering: window icon
This commit is contained in:
parent
e6fd5d5f54
commit
1c61ffb440
@ -150,6 +150,7 @@ class RenderWindow(
|
|||||||
val stopwatch = Stopwatch()
|
val stopwatch = Stopwatch()
|
||||||
|
|
||||||
window.init()
|
window.init()
|
||||||
|
window.setDefaultIcon(connection.assetsManager)
|
||||||
|
|
||||||
inputHandler.camera.init(this)
|
inputHandler.camera.init(this)
|
||||||
|
|
||||||
|
@ -15,8 +15,13 @@ package de.bixilon.minosoft.gui.rendering.system.window
|
|||||||
|
|
||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.config.StaticConfiguration
|
import de.bixilon.minosoft.config.StaticConfiguration
|
||||||
|
import de.bixilon.minosoft.data.assets.AssetsManager
|
||||||
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
import de.matthiasmann.twl.utils.PNGDecoder
|
||||||
import glm_.vec2.Vec2
|
import glm_.vec2.Vec2
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
|
import org.lwjgl.BufferUtils
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
interface BaseWindow {
|
interface BaseWindow {
|
||||||
var size: Vec2i
|
var size: Vec2i
|
||||||
@ -61,6 +66,18 @@ interface BaseWindow {
|
|||||||
|
|
||||||
fun setOpenGLVersion(major: Int, minor: Int, coreProfile: Boolean)
|
fun setOpenGLVersion(major: Int, minor: Int, coreProfile: Boolean)
|
||||||
|
|
||||||
|
|
||||||
|
fun setIcon(size: Vec2i, buffer: ByteBuffer)
|
||||||
|
|
||||||
|
|
||||||
|
fun setDefaultIcon(assetsManager: AssetsManager) {
|
||||||
|
val decoder = PNGDecoder(assetsManager.readAssetAsStream("minosoft:textures/icons/window_icon.png".toResourceLocation()))
|
||||||
|
val data = BufferUtils.createByteBuffer(decoder.width * decoder.height * PNGDecoder.Format.RGBA.numComponents)
|
||||||
|
decoder.decode(data, decoder.width * PNGDecoder.Format.RGBA.numComponents, PNGDecoder.Format.RGBA)
|
||||||
|
data.flip()
|
||||||
|
setIcon(Vec2i(decoder.width, decoder.height), data)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT_WINDOW_SIZE: Vec2i
|
val DEFAULT_WINDOW_SIZE: Vec2i
|
||||||
get() = Vec2i(900, 500)
|
get() = Vec2i(900, 500)
|
||||||
|
@ -35,7 +35,9 @@ import glm_.vec2.Vec2i
|
|||||||
import org.lwjgl.glfw.Callbacks.glfwFreeCallbacks
|
import org.lwjgl.glfw.Callbacks.glfwFreeCallbacks
|
||||||
import org.lwjgl.glfw.GLFW.*
|
import org.lwjgl.glfw.GLFW.*
|
||||||
import org.lwjgl.glfw.GLFWErrorCallback
|
import org.lwjgl.glfw.GLFWErrorCallback
|
||||||
|
import org.lwjgl.glfw.GLFWImage
|
||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
|
|
||||||
class GLFWWindow(
|
class GLFWWindow(
|
||||||
@ -280,6 +282,14 @@ class GLFWWindow(
|
|||||||
eventMaster.fireEvent(MouseScrollEvent(offset = Vec2d(xOffset, yOffset)))
|
eventMaster.fireEvent(MouseScrollEvent(offset = Vec2d(xOffset, yOffset)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setIcon(size: Vec2i, buffer: ByteBuffer) {
|
||||||
|
val images = GLFWImage.malloc(1)
|
||||||
|
val image = GLFWImage.malloc()
|
||||||
|
image.set(size.x, size.y, buffer)
|
||||||
|
images.put(0, image)
|
||||||
|
glfwSetWindowIcon(window, images)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val CursorModes.glfw: Int
|
val CursorModes.glfw: Int
|
||||||
get() {
|
get() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user