aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/render/FirmamentShaders.kt
blob: ba67dbba142958f598908a5f1f0ba611dabf9e66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package moe.nea.firmament.util.render

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.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
	}

	val LINES = RenderPhase.ShaderProgram(shader("core/rendertype_lines", VertexFormats.LINES, Defines.EMPTY))

	@Subscribe
	fun debugLoad(event: DebugInstantiateEvent) {
		shaders.forEach {
			MC.instance.shaderLoader.getOrCreateProgram(it)
		}
	}
}