diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-19 18:20:55 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-19 18:20:55 +0200 |
commit | 5aa969979ab1dd0e64e5b569cc3b7b281b3e536f (patch) | |
tree | 55a7b8029dc76fd44078bca056fe31ac2f76833b /src/main/kotlin/util/render/ScreenRenderUtils.kt | |
parent | 3d7ace2e0fd66a2c83222d35331b27783268deea (diff) | |
download | ultra-notifier-master.tar.gz ultra-notifier-master.tar.bz2 ultra-notifier-master.zip |
Diffstat (limited to 'src/main/kotlin/util/render/ScreenRenderUtils.kt')
-rw-r--r-- | src/main/kotlin/util/render/ScreenRenderUtils.kt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/kotlin/util/render/ScreenRenderUtils.kt b/src/main/kotlin/util/render/ScreenRenderUtils.kt new file mode 100644 index 0000000..6a659bf --- /dev/null +++ b/src/main/kotlin/util/render/ScreenRenderUtils.kt @@ -0,0 +1,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() + } +} |