summaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/render/ScreenRenderUtils.kt
blob: 6a659bf2b21659413aa1ba6431a61d20b94d6abd (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
31
32
33
34
35
36
37
38
39
package moe.nea.ultranotifier.util.render

import gg.essential.universal.UGraphics
import gg.essential.universal.UMatrixStack
import net.minecraft.util.Identifier
import java.awt.Color

object ScreenRenderUtils {
	fun fillRect(
		matrixStack: UMatrixStack,
		left: Double, top: Double,
		right: Double, bottom: Double,
		color: Color,
	) {
		val buffer = UGraphics.getFromTessellator()
		buffer.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_COLOR)
		buffer.pos(matrixStack, left, top, 0.0).color(color).endVertex()
		buffer.pos(matrixStack, left, bottom, 0.0).color(color).endVertex()
		buffer.pos(matrixStack, right, bottom, 0.0).color(color).endVertex()
		buffer.pos(matrixStack, right, top, 0.0).color(color).endVertex()
		buffer.drawDirect()
	}

	fun renderTexture(
		identifier: Identifier,
		matrixStack: UMatrixStack,
		left: Double, top: Double,
		right: Double, bottom: Double,
	) {
		UGraphics.bindTexture(0, identifier)
		val graphics = UGraphics.getFromTessellator()
		graphics.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_TEXTURE)
		graphics.pos(matrixStack, left, top, 0.0).tex(0.0, 0.0).endVertex()
		graphics.pos(matrixStack, left, bottom, 0.0).tex(0.0, 1.0).endVertex()
		graphics.pos(matrixStack, right, bottom, 0.0).tex(1.0, 1.0).endVertex()
		graphics.pos(matrixStack, right, top, 0.0).tex(1.0, 0.0).endVertex()
		graphics.drawDirect()
	}
}