aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java40
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);
}
}