diff options
author | Appability <appable@icloud.com> | 2022-10-21 23:33:52 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2022-10-21 23:33:52 -0700 |
commit | 4f25e7948c7e85151a80c17f7d2b25b72675cecf (patch) | |
tree | 7e152610a0f80f40f5524a231a157ea81ffab0e3 /src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt | |
parent | 1c3359e42f38012dae182e75200cc1f364dcda8f (diff) | |
download | AmbientAddons-4f25e7948c7e85151a80c17f7d2b25b72675cecf.tar.gz AmbientAddons-4f25e7948c7e85151a80c17f7d2b25b72675cecf.tar.bz2 AmbientAddons-4f25e7948c7e85151a80c17f7d2b25b72675cecf.zip |
moving gui stuff (attempt 1)
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt')
-rw-r--r-- | src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt b/src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt index 69f3c99..084bf1d 100644 --- a/src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt +++ b/src/main/kotlin/com/ambientaddons/utils/render/OverlayUtils.kt @@ -7,6 +7,8 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.vertex.DefaultVertexFormats +import org.lwjgl.opengl.GL11.GL_QUADS +import java.awt.Color import kotlin.math.roundToInt object OverlayUtils { @@ -71,4 +73,37 @@ object OverlayUtils { } } + + fun renderRect(x: Double, y: Double, w: Double, h: Double, color: Color) { + if (color.alpha == 0) return + GlStateManager.enableBlend() + GlStateManager.disableTexture2D() + GlStateManager.enableAlpha() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f) + + worldRenderer.begin(GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(x, y + h, 0.0).endVertex() + worldRenderer.pos(x + w, y + h, 0.0).endVertex() + worldRenderer.pos(x + w, y, 0.0).endVertex() + worldRenderer.pos(x, y, 0.0).endVertex() + tessellator.draw() + + GlStateManager.disableAlpha() + GlStateManager.enableTexture2D() + GlStateManager.disableBlend() + } + + private val tessellator: Tessellator = Tessellator.getInstance() + private val worldRenderer: WorldRenderer = tessellator.worldRenderer + + fun drawTexturedModalRect(x: Int, y: Int, width: Int, height: Int) { + worldRenderer.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX) + worldRenderer.pos(x.toDouble(), (y + height).toDouble(), 0.0).tex(0.0, 1.0).endVertex() + worldRenderer.pos((x + width).toDouble(), (y + height).toDouble(), 0.0).tex(1.0, 1.0).endVertex() + worldRenderer.pos((x + width).toDouble(), y.toDouble(), 0.0).tex(1.0, 0.0).endVertex() + worldRenderer.pos(x.toDouble(), y.toDouble(), 0.0).tex(0.0, 0.0).endVertex() + tessellator.draw() + } + }
\ No newline at end of file |