diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-03 01:24:24 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-09 01:01:18 +0100 |
commit | 22f0cc59a2d3bc7900764e3916c670075ff9d35e (patch) | |
tree | b503ff607cf818a539cbbaa403f6851ef979e03d /src/main/kotlin/util/render/FirmamentShaders.kt | |
parent | 646843ba3b960ac48f9866b3640438d3cc1dafc4 (diff) | |
download | Firmament-22f0cc59a2d3bc7900764e3916c670075ff9d35e.tar.gz Firmament-22f0cc59a2d3bc7900764e3916c670075ff9d35e.tar.bz2 Firmament-22f0cc59a2d3bc7900764e3916c670075ff9d35e.zip |
1.21.3 WIP
Diffstat (limited to 'src/main/kotlin/util/render/FirmamentShaders.kt')
-rw-r--r-- | src/main/kotlin/util/render/FirmamentShaders.kt | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/main/kotlin/util/render/FirmamentShaders.kt b/src/main/kotlin/util/render/FirmamentShaders.kt index 1094bc2..ba67dbb 100644 --- a/src/main/kotlin/util/render/FirmamentShaders.kt +++ b/src/main/kotlin/util/render/FirmamentShaders.kt @@ -1,23 +1,30 @@ package moe.nea.firmament.util.render -import net.minecraft.client.gl.ShaderProgram +import net.minecraft.client.gl.Defines +import net.minecraft.client.gl.ShaderProgramKey import net.minecraft.client.render.RenderPhase +import net.minecraft.client.render.VertexFormat import net.minecraft.client.render.VertexFormats +import moe.nea.firmament.Firmament import moe.nea.firmament.annotations.Subscribe -import moe.nea.firmament.events.RegisterCustomShadersEvent +import moe.nea.firmament.events.DebugInstantiateEvent +import moe.nea.firmament.util.MC object FirmamentShaders { + val shaders = mutableListOf<ShaderProgramKey>() + private fun shader(name: String, format: VertexFormat, defines: Defines): ShaderProgramKey { + val key = ShaderProgramKey(Firmament.identifier(name), format, defines) + shaders.add(key) + return key + } - private lateinit var _LINES: ShaderProgram - val LINES = RenderPhase.ShaderProgram({ _LINES }) + val LINES = RenderPhase.ShaderProgram(shader("core/rendertype_lines", VertexFormats.LINES, Defines.EMPTY)) - @Subscribe - fun registerCustomShaders(event: RegisterCustomShadersEvent) { - event.register( - "firmament_rendertype_lines", - VertexFormats.LINES, - { _LINES = it }, - ) - } + @Subscribe + fun debugLoad(event: DebugInstantiateEvent) { + shaders.forEach { + MC.instance.shaderLoader.getOrCreateProgram(it) + } + } } |