diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-09-28 22:50:53 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-09-28 22:50:53 -0700 |
commit | 211793ac73a3aaa98835c9ac25fa4583a72bb03a (patch) | |
tree | 9ca392237bd42528f0c2c688684a44681c4508f7 /src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java | |
parent | 576cb9778a43f59430fc7c0403719368a08b5889 (diff) | |
download | Iceberg-211793ac73a3aaa98835c9ac25fa4583a72bb03a.tar.gz Iceberg-211793ac73a3aaa98835c9ac25fa4583a72bb03a.tar.bz2 Iceberg-211793ac73a3aaa98835c9ac25fa4583a72bb03a.zip |
Added GuiHelper class with generic rendering helpers. Added color
easing helper function.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java new file mode 100644 index 0000000..4325ebe --- /dev/null +++ b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java @@ -0,0 +1,43 @@ +package com.anthonyhilyard.iceberg.util; + +import org.lwjgl.opengl.GL11; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.math.vector.Matrix4f; + +public class GuiHelper +{ + @SuppressWarnings("deprecation") + public static void drawGradientRectHorizontal(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) + { + float startAlpha = (float)(startColor >> 24 & 255) / 255.0F; + float startRed = (float)(startColor >> 16 & 255) / 255.0F; + float startGreen = (float)(startColor >> 8 & 255) / 255.0F; + float startBlue = (float)(startColor & 255) / 255.0F; + float endAlpha = (float)(endColor >> 24 & 255) / 255.0F; + float endRed = (float)(endColor >> 16 & 255) / 255.0F; + float endGreen = (float)(endColor >> 8 & 255) / 255.0F; + float endBlue = (float)(endColor & 255) / 255.0F; + + RenderSystem.enableDepthTest(); + RenderSystem.disableTexture(); + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + RenderSystem.shadeModel(GL11.GL_SMOOTH); + + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder buffer = tessellator.getBuilder(); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); + buffer.vertex(mat, right, top, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex(); + buffer.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); + buffer.vertex(mat, left, bottom, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); + buffer.vertex(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex(); + tessellator.end(); + + RenderSystem.shadeModel(GL11.GL_FLAT); + RenderSystem.disableBlend(); + RenderSystem.enableTexture(); + } +} |