Skip to content

Commit

Permalink
Add helper methods for setting the shader color
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jun 28, 2024
1 parent bffead6 commit b50e89a
Show file tree
Hide file tree
Showing 31 changed files with 108 additions and 133 deletions.
31 changes: 12 additions & 19 deletions src/main/java/net/wurstclient/clickgui/ClickGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,7 @@ public void renderTooltip(DrawContext context, int mouseX, int mouseY)
RenderSystem.setShader(GameRenderer::getPositionProgram);

// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
ttOpacity);
RenderUtils.setShaderColor(bgColor, ttOpacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, xt1, yt1, 0);
Expand All @@ -573,7 +572,7 @@ public void renderTooltip(DrawContext context, int mouseX, int mouseY)
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// outline
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, xt1, yt1, 0);
Expand Down Expand Up @@ -673,8 +672,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,
int ys4 = ys3 + (int)scrollbarHeight;

// window background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -696,7 +694,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,
&& mouseX < xs2 && mouseY < ys4;

// scrollbar
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2],
RenderUtils.setShaderColor(acColor,
hovering ? opacity * 1.5F : opacity);

bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
Expand All @@ -708,8 +706,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// outline
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2],
0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);

bufferBuilder =
tessellator.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP,
Expand All @@ -729,8 +726,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,

// window background
// left & right
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -754,8 +750,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,
matrixStack.translate(x1, y4, 0);
matrix = matrixStack.peek().getPositionMatrix();

RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);
bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);

Expand Down Expand Up @@ -808,7 +803,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

// window outline
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);

BufferBuilder bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
Expand Down Expand Up @@ -862,8 +857,7 @@ private void renderWindow(DrawContext context, Window window, int mouseX,

// title bar background
// above & below buttons
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2],
opacity);
RenderUtils.setShaderColor(acColor, opacity);

bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
Expand Down Expand Up @@ -906,7 +900,7 @@ private void renderTitleBarButton(MatrixStack matrixStack, int x1, int y1,
RenderSystem.setShader(GameRenderer::getPositionProgram);

// button background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
RenderUtils.setShaderColor(bgColor,
hovering ? opacity * 1.5F : opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -917,8 +911,7 @@ private void renderTitleBarButton(MatrixStack matrixStack, int x1, int y1,
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// background between buttons
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2],
opacity);
RenderUtils.setShaderColor(acColor, opacity);
bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x2, y1, 0);
Expand All @@ -928,7 +921,7 @@ private void renderTitleBarButton(MatrixStack matrixStack, int x1, int y1,
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// button outline
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/wurstclient/clickgui/ComboBoxPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.wurstclient.WurstClient;
import net.wurstclient.settings.EnumSetting;
import net.wurstclient.util.RenderUtils;

public final class ComboBoxPopup<T extends Enum<T>> extends Popup
{
Expand Down Expand Up @@ -117,7 +118,7 @@ private void drawOutline(MatrixStack matrixStack, int x1, int x2, int y1,
Tessellator tessellator = RenderSystem.renderThreadTesselator();

float[] acColor = gui.getAcColor();
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);

BufferBuilder bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
Expand All @@ -138,7 +139,7 @@ private void drawValueBackground(MatrixStack matrixStack, int x1, int x2,
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();

RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2], alpha);
RenderUtils.setShaderColor(bgColor, alpha);

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.wurstclient.clickgui.ClickGui;
import net.wurstclient.clickgui.Component;
import net.wurstclient.settings.Setting;
import net.wurstclient.util.RenderUtils;

public abstract class AbstractListEditButton extends Component
{
Expand Down Expand Up @@ -91,8 +92,7 @@ public void render(DrawContext context, int mouseX, int mouseY,
gui.setTooltip(getSetting().getWrappedDescription(200));

// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0);
Expand All @@ -102,16 +102,15 @@ public void render(DrawContext context, int mouseX, int mouseY,
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// box
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
hBox ? opacity * 1.5F : opacity);
RenderUtils.setShaderColor(bgColor, hBox ? opacity * 1.5F : opacity);
bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0);
bufferBuilder.vertex(matrix, x3, y2, 0);
bufferBuilder.vertex(matrix, x2, y2, 0);
bufferBuilder.vertex(matrix, x2, y1, 0);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ else if(hBlock)
}

// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.wurstclient.clickgui.Component;
import net.wurstclient.clickgui.Window;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.util.RenderUtils;

public final class CheckboxComponent extends Component
{
Expand Down Expand Up @@ -119,8 +120,7 @@ private void drawBackground(MatrixStack matrixStack, int x2, int x3, int y1,
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();

RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0);
Expand All @@ -140,7 +140,7 @@ private void drawBox(MatrixStack matrixStack, int x1, int x3, int y1,
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();

RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
RenderUtils.setShaderColor(bgColor,
hovering ? opacity * 1.5F : opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -150,7 +150,7 @@ private void drawBox(MatrixStack matrixStack, int x1, int x3, int y1,
bufferBuilder.vertex(matrix, x3, y1, 0);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.wurstclient.clickgui.screens.EditColorScreen;
import net.wurstclient.settings.ColorSetting;
import net.wurstclient.util.ColorUtils;
import net.wurstclient.util.RenderUtils;

public final class ColorComponent extends Component
{
Expand Down Expand Up @@ -110,8 +111,7 @@ private void drawBackground(MatrixStack matrixStack, int x1, int x2, int y1,
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();

RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -133,8 +133,7 @@ private void drawBox(MatrixStack matrixStack, int x1, int x2, int y2,
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();

RenderSystem.setShaderColor(color[0], color[1], color[2],
hovering ? 1F : opacity);
RenderUtils.setShaderColor(color, hovering ? 1F : opacity);

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -144,7 +143,7 @@ private void drawBox(MatrixStack matrixStack, int x1, int x2, int y2,
bufferBuilder.vertex(matrix, x2, y2, 0);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);

bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.wurstclient.clickgui.Component;
import net.wurstclient.clickgui.Window;
import net.wurstclient.settings.EnumSetting;
import net.wurstclient.util.RenderUtils;

public final class ComboBoxComponent<T extends Enum<T>> extends Component
{
Expand Down Expand Up @@ -154,8 +155,7 @@ private void drawBackground(MatrixStack matrixStack, int x1, int x4, int y1,
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();

RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
Expand All @@ -178,8 +178,7 @@ private void drawBox(MatrixStack matrixStack, int x2, int x4, int y1,

// background
float bgAlpha = hBox ? opacity * 1.5F : opacity;
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
bgAlpha);
RenderUtils.setShaderColor(bgColor, bgAlpha);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x4, y1, 0);
Expand All @@ -189,7 +188,7 @@ private void drawBox(MatrixStack matrixStack, int x2, int x4, int y1,
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// outline
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x4, y1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.wurstclient.clickgui.Window;
import net.wurstclient.hacks.TooManyHaxHack;
import net.wurstclient.util.ChatUtils;
import net.wurstclient.util.RenderUtils;

public final class FeatureButton extends Component
{
Expand Down Expand Up @@ -179,7 +180,7 @@ private void drawButtonBackground(MatrixStack matrixStack, int x1, int x3,
RenderSystem.setShaderColor(0, 1, 0,
hHack ? opacity * 1.5F : opacity);
else
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
RenderUtils.setShaderColor(bgColor,
hHack ? opacity * 1.5F : opacity);

bufferBuilder.vertex(matrix, x1, y1, 0);
Expand All @@ -201,7 +202,7 @@ private void drawSettingsBackground(MatrixStack matrixStack, int x2, int x3,

BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
RenderUtils.setShaderColor(bgColor,
hSettings ? opacity * 1.5F : opacity);
bufferBuilder.vertex(matrix, x3, y1, 0);
bufferBuilder.vertex(matrix, x3, y2, 0);
Expand All @@ -220,7 +221,7 @@ private void drawOutline(MatrixStack matrixStack, int x1, int x2, int y1,

BufferBuilder bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder.vertex(matrix, x1, y1, 0);
bufferBuilder.vertex(matrix, x1, y2, 0);
bufferBuilder.vertex(matrix, x2, y2, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.wurstclient.clickgui.Component;
import net.wurstclient.clickgui.screens.SelectFileScreen;
import net.wurstclient.settings.FileSetting;
import net.wurstclient.util.RenderUtils;

public final class FileComponent extends Component
{
Expand Down Expand Up @@ -97,8 +98,7 @@ else if(hBox)
}

// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0);
Expand All @@ -108,16 +108,15 @@ else if(hBox)
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

// box
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
hBox ? opacity * 1.5F : opacity);
RenderUtils.setShaderColor(bgColor, hBox ? opacity * 1.5F : opacity);
bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0);
bufferBuilder.vertex(matrix, x3, y2, 0);
bufferBuilder.vertex(matrix, x2, y2, 0);
bufferBuilder.vertex(matrix, x2, y1, 0);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
RenderUtils.setShaderColor(acColor, 0.5F);
bufferBuilder = tessellator.begin(
VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.wurstclient.clickgui.Component;
import net.wurstclient.hacks.RadarHack;
import net.wurstclient.util.EntityUtils;
import net.wurstclient.util.RenderUtils;

public final class RadarComponent extends Component
{
Expand Down Expand Up @@ -77,8 +78,7 @@ public void render(DrawContext context, int mouseX, int mouseY,
gui.setTooltip("");

// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
RenderUtils.setShaderColor(bgColor, opacity);
BufferBuilder bufferBuilder = tessellator
.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0);
Expand Down Expand Up @@ -107,8 +107,7 @@ public void render(DrawContext context, int mouseX, int mouseY,
float ya3 = 1;

// arrow
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2],
opacity);
RenderUtils.setShaderColor(acColor, opacity);
bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, xa1, ya1, 0);
Expand Down
Loading

0 comments on commit b50e89a

Please sign in to comment.