aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2023-09-27 15:00:32 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2023-09-27 15:00:32 +0300
commit502805b98ffdda6fb051f530b7fda2b776edf57d (patch)
tree3e0669b7938fe3e4ea7317eb75f5d7c65d57f111 /src
parentf719ee5f3243d8a0e436181a2b23a2e35731ae67 (diff)
downloadLibGui-502805b98ffdda6fb051f530b7fda2b776edf57d.tar.gz
LibGui-502805b98ffdda6fb051f530b7fda2b776edf57d.tar.bz2
LibGui-502805b98ffdda6fb051f530b7fda2b776edf57d.zip
ScreenDrawing: Fix texturedRect not respecting alpha values
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
index 9682766..6ddc9c0 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
@@ -115,7 +115,9 @@ public class ScreenDrawing {
float r = (color >> 16 & 255) / 255.0F;
float g = (color >> 8 & 255) / 255.0F;
float b = (color & 255) / 255.0F;
- RenderSystem.setShaderColor(r, g, b, opacity);
+ float a = (color >> 24 & 255) / 255.0F;
+ RenderSystem.enableBlend();
+ RenderSystem.setShaderColor(r, g, b, opacity * a);
outer: if (texture.u1() == 0 && texture.u2() == 1 && texture.v1() == 0 && texture.v2() == 1) {
// If we're drawing the full texture, just let vanilla do it.
@@ -150,6 +152,7 @@ public class ScreenDrawing {
matrices.pop();
}
+ RenderSystem.disableBlend();
// Don't let the color cause tinting to other draw calls.
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@@ -180,12 +183,13 @@ public class ScreenDrawing {
float r = (color >> 16 & 255) / 255.0F;
float g = (color >> 8 & 255) / 255.0F;
float b = (color & 255) / 255.0F;
+ float a = (color >> 24 & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
Matrix4f model = context.getMatrices().peek().getPositionMatrix();
RenderSystem.enableBlend();
RenderSystem.setShaderTexture(0, texture);
- RenderSystem.setShaderColor(r, g, b, opacity);
+ RenderSystem.setShaderColor(r, g, b, opacity * a);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
buffer.vertex(model, x, y + height, 0).texture(u1, v2).next();