aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
index f9395d3..9e7842f 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
@@ -4,12 +4,31 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.GameRenderer;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.math.Matrix4f;
public class GuiHelper
{
+ public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
+ {
+ RenderSystem.enableDepthTest();
+ RenderSystem.disableTexture();
+ RenderSystem.enableBlend();
+ RenderSystem.defaultBlendFunc();
+ RenderSystem.setShader(GameRenderer::getPositionColorShader);
+
+ Tesselator tessellator = Tesselator.getInstance();
+ BufferBuilder bufferBuilder = tessellator.getBuilder();
+ drawGradientRect(mat, bufferBuilder, left, top, right, bottom, zLevel, startColor, endColor);
+ bufferBuilder.end();
+ BufferUploader.end(bufferBuilder);
+
+ RenderSystem.disableBlend();
+ RenderSystem.enableTexture();
+ }
+
public static void drawGradientRect(Matrix4f mat, BufferBuilder bufferBuilder, int left, int top, int right, int bottom, int zLevel, int startColor, int endColor)
{
float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
@@ -20,6 +39,7 @@ public class GuiHelper
float endRed = (float)(endColor >> 16 & 255) / 255.0F;
float endGreen = (float)(endColor >> 8 & 255) / 255.0F;
float endBlue = (float)(endColor & 255) / 255.0F;
+
bufferBuilder.vertex(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
bufferBuilder.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
bufferBuilder.vertex(mat, left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
@@ -44,12 +64,12 @@ public class GuiHelper
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tesselator tessellator = Tesselator.getInstance();
- BufferBuilder buffer = tessellator.getBuilder();
- buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.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();
+ BufferBuilder bufferBuilder = tessellator.getBuilder();
+ bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
+ bufferBuilder.vertex(mat, right, top, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
+ bufferBuilder.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ bufferBuilder.vertex(mat, left, bottom, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ bufferBuilder.vertex(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
tessellator.end();
RenderSystem.disableBlend();