aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/zeitheron/hammercore
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-05-09 22:38:34 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-05-09 22:38:34 +0800
commitc1b0219e8d5458ddf1eccc194d34893f698b7d88 (patch)
treea0ed116ad122b66721c5fe9345925e04f3c73a47 /src/main/java/com/zeitheron/hammercore
parent6017255b2b2704031a784eafd2bd720f1e7b8fc2 (diff)
downloadRoughlyEnoughItems-c1b0219e8d5458ddf1eccc194d34893f698b7d88.tar.gz
RoughlyEnoughItems-c1b0219e8d5458ddf1eccc194d34893f698b7d88.tar.bz2
RoughlyEnoughItems-c1b0219e8d5458ddf1eccc194d34893f698b7d88.zip
VillagerRecipeViewingScreen done
Diffstat (limited to 'src/main/java/com/zeitheron/hammercore')
-rw-r--r--src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java
new file mode 100644
index 000000000..36d56329d
--- /dev/null
+++ b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java
@@ -0,0 +1,38 @@
+package com.zeitheron.hammercore.client.utils;
+
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.util.Window;
+import org.lwjgl.opengl.GL11;
+
+/**
+ * This is originally the part of Hammer Lib, repacked in REI with permission.
+ * Adapted GL scissor for minecraft pixel resolution and adjusts (0;0) as left-top corner.
+ *
+ * @author Zeitheron
+ */
+public class Scissors {
+ public static void begin() {
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ }
+
+ public static void scissor(int x, int y, int width, int height) {
+ Window window = MinecraftClient.getInstance().window;
+
+ int sw = window.getWidth();
+ int sh = window.getHeight();
+ float dw = window.getScaledWidth();
+ float dh = window.getScaledHeight();
+
+ x = Math.round(sw * (x / dw));
+ y = Math.round(sh * (y / dh));
+
+ width = Math.round(sw * (width / dw));
+ height = Math.round(sh * (height / dh));
+
+ GL11.glScissor(x, sh - height - y, width, height);
+ }
+
+ public static void end() {
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ }
+} \ No newline at end of file