mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 00:47:26 -04:00
hot shader reloading
This commit is contained in:
parent
c669a1dafe
commit
db2e9c5c86
@ -130,6 +130,14 @@ interface RenderSystem {
|
||||
setBlendFunction(BlendingFunctions.ONE, BlendingFunctions.ONE_MINUS_SOURCE_ALPHA, BlendingFunctions.ONE, BlendingFunctions.ZERO)
|
||||
}
|
||||
|
||||
@Deprecated("Highly unstable")
|
||||
fun reloadShaders() {
|
||||
val copy = shaders.toMutableSet()
|
||||
for (shader in copy) {
|
||||
shader.reload()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -34,6 +34,10 @@ interface Shader {
|
||||
val log: String
|
||||
|
||||
fun load()
|
||||
fun unload()
|
||||
|
||||
@Deprecated("Highly buggy, do not use in normal environment")
|
||||
fun reload()
|
||||
|
||||
fun use(): Shader {
|
||||
renderWindow.renderSystem.shader = this
|
||||
|
@ -105,6 +105,19 @@ class OpenGLShader(
|
||||
renderWindow.renderSystem.shaders += this
|
||||
}
|
||||
|
||||
override fun unload() {
|
||||
check(loaded) { "Not loaded!" }
|
||||
glDeleteProgram(this.shader)
|
||||
loaded = false
|
||||
this.shader = -1
|
||||
renderWindow.renderSystem.shaders -= this
|
||||
}
|
||||
|
||||
override fun reload() {
|
||||
unload()
|
||||
load()
|
||||
}
|
||||
|
||||
|
||||
private fun getUniformLocation(uniformName: String): Int {
|
||||
val location = uniformLocations.getOrPut(uniformName) {
|
||||
|
@ -14,11 +14,13 @@
|
||||
package de.bixilon.minosoft.terminal.commands
|
||||
|
||||
import de.bixilon.minosoft.terminal.commands.connection.SayCommand
|
||||
import de.bixilon.minosoft.terminal.commands.rendering.ReloadCommand
|
||||
|
||||
object Commands {
|
||||
val COMMANDS: List<Command> = listOf(
|
||||
HelpCommand,
|
||||
SayCommand,
|
||||
ConnectionManageCommand,
|
||||
ReloadCommand,
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.terminal.commands.rendering
|
||||
|
||||
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||
|
||||
object ReloadCommand : RenderingCommand {
|
||||
override var node = LiteralNode("reload", setOf("rl"))
|
||||
.addChild(LiteralNode("shaders", executor = {
|
||||
it.connection.rendering!!.renderWindow.renderSystem.reloadShaders()
|
||||
it.connection.util.sendDebugMessage("Shaders reloaded!")
|
||||
}))
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.terminal.commands.rendering
|
||||
|
||||
import de.bixilon.minosoft.terminal.commands.Command
|
||||
|
||||
interface RenderingCommand : Command
|
Loading…
x
Reference in New Issue
Block a user