diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-01-20 19:49:03 +0200 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-01-20 19:49:03 +0200 |
commit | e413c03201f943200a3abcd8e9444335705e71ab (patch) | |
tree | b3ed405dec2524266d96ab1f6dd06a11b01f1024 | |
parent | 993c1e793b35bd6a356f8a5b96c551aa954d8116 (diff) | |
download | LibGui-e413c03201f943200a3abcd8e9444335705e71ab.tar.gz LibGui-e413c03201f943200a3abcd8e9444335705e71ab.tar.bz2 LibGui-e413c03201f943200a3abcd8e9444335705e71ab.zip |
Fix WClippedPanel
It now uses a glScissor instead of a depth hack.
I tested it with the config GUI, and it seems to work.
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java index 342ba33..23acfc0 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java @@ -2,14 +2,17 @@ package io.github.cottonmc.cotton.gui.widget; import org.lwjgl.opengl.GL11; -import com.mojang.blaze3d.systems.RenderSystem; - -import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import net.minecraft.client.MinecraftClient; import net.minecraft.util.Identifier; public class WClippedPanel extends WPanel { + @Deprecated protected Identifier mask; - + + /** + * @deprecated {@code WClippedPanel} does not support clipping masks anymore. + */ + @Deprecated public WClippedPanel setClippingMask(Identifier mask) { this.mask = mask; return this; @@ -18,27 +21,18 @@ public class WClippedPanel extends WPanel { @Override public void paintBackground(int x, int y, int mouseX, int mouseY) { if (getBackgroundPainter()!=null) getBackgroundPainter().paintBackground(x, y, this); - - RenderSystem.translatef(0, 0, 10); - //RenderSystem.depthFunc(GL11.GL_LEQUAL); - //RenderSystem.disableDepthTest(); - - - RenderSystem.colorMask(false, false, false, true); - if (mask!=null) { - ScreenDrawing.texturedRect(x, y, getWidth(), getHeight(), mask, 0xFFFFFFFF); - } else { - ScreenDrawing.coloredRect(x, y, getWidth(), getHeight(), 0xFFFFFFFF); - } - RenderSystem.colorMask(true, true, true, true); - + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + MinecraftClient mc = MinecraftClient.getInstance(); + double scaleFactor = mc.getWindow().getScaleFactor(); + int scaledWidth = (int) (getWidth() * scaleFactor); + int scaledHeight = (int) (getHeight() * scaleFactor); + GL11.glScissor((int) (x * scaleFactor), (int) ((y + scaleFactor * (1 - this.y + 18)) * scaleFactor), scaledWidth, scaledHeight); + for(WWidget child : children) { - RenderSystem.enableDepthTest(); - RenderSystem.depthFunc(GL11.GL_GEQUAL); child.paintBackground(x + child.getX(), y + child.getY(), mouseX-child.getX(), mouseY-child.getY()); } - RenderSystem.translated(0, 0, -10); - RenderSystem.depthFunc(GL11.GL_LEQUAL); - RenderSystem.disableDepthTest(); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); } } |