Window icon
This commit is contained in:
parent
19c3da7b8f
commit
8fe6da7218
@ -8,11 +8,14 @@ import org.lwjgl.BufferUtils
|
|||||||
import org.lwjgl.glfw.Callbacks
|
import org.lwjgl.glfw.Callbacks
|
||||||
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.opengl.GL
|
import org.lwjgl.opengl.GL
|
||||||
import org.lwjgl.opengl.GL45.*
|
import org.lwjgl.opengl.GL45.*
|
||||||
import org.lwjgl.opengl.GLCapabilities
|
import org.lwjgl.opengl.GLCapabilities
|
||||||
|
import org.lwjgl.stb.STBImage
|
||||||
import org.lwjgl.system.MemoryStack
|
import org.lwjgl.system.MemoryStack
|
||||||
import org.lwjgl.system.MemoryUtil
|
import org.lwjgl.system.MemoryUtil
|
||||||
|
import org.lwjgl.system.MemoryUtil.memAddressSafe
|
||||||
import ru.dbotthepony.kstarbound.util.MailboxExecutorService
|
import ru.dbotthepony.kstarbound.util.MailboxExecutorService
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNIT
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNIT
|
||||||
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
import ru.dbotthepony.kstarbound.world.PIXELS_IN_STARBOUND_UNITf
|
||||||
@ -238,7 +241,7 @@ class StarboundClient : Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val stack = MemoryStack.stackPush()
|
var stack = MemoryStack.stackPush()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val pWidth = stack.mallocInt(1)
|
val pWidth = stack.mallocInt(1)
|
||||||
@ -261,6 +264,28 @@ class StarboundClient : Closeable {
|
|||||||
stack.close()
|
stack.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stack = MemoryStack.stackPush()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val pWidth = stack.mallocInt(1)
|
||||||
|
val pHeight = stack.mallocInt(1)
|
||||||
|
val pChannels = stack.mallocInt(1)
|
||||||
|
|
||||||
|
val readFromDisk = readInternalBytes("starbound.png")
|
||||||
|
val buff = ByteBuffer.allocateDirect(readFromDisk.size)
|
||||||
|
buff.put(readFromDisk)
|
||||||
|
buff.position(0)
|
||||||
|
|
||||||
|
val data = STBImage.stbi_load_from_memory(buff, pWidth, pHeight, pChannels, 4) ?: throw IllegalStateException("Unable to decode starbound.png")
|
||||||
|
val img = GLFWImage.malloc()
|
||||||
|
img.set(pWidth[0], pHeight[0], data)
|
||||||
|
|
||||||
|
GLFW.nglfwSetWindowIcon(window, 1, memAddressSafe(img))
|
||||||
|
img.free()
|
||||||
|
} finally {
|
||||||
|
stack.close()
|
||||||
|
}
|
||||||
|
|
||||||
// vsync
|
// vsync
|
||||||
GLFW.glfwSwapInterval(0)
|
GLFW.glfwSwapInterval(0)
|
||||||
|
|
||||||
@ -1068,5 +1093,10 @@ class StarboundClient : Closeable {
|
|||||||
read
|
read
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun readInternalBytes(file: String): ByteArray {
|
||||||
|
return ClassLoader.getSystemClassLoader().getResourceAsStream(file)!!.readAllBytes()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/main/resources/starbound.png
Normal file
BIN
src/main/resources/starbound.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue
Block a user