diff options
| author | Daniel She <shekwancheung0528@gmail.com> | 2019-05-10 00:20:16 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-10 00:20:16 +0800 |
| commit | 67fc756047f34bdbb9f028e48fc725534b3beafc (patch) | |
| tree | 670f0694b3313eaf712020a9d60dc34404725777 /src/main/java/com | |
| parent | 766b4837c2512cefa3188adc897605a83144f711 (diff) | |
| parent | 467511401a783fc0a8d625947e69519da1c815e1 (diff) | |
| download | RoughlyEnoughItems-67fc756047f34bdbb9f028e48fc725534b3beafc.tar.gz RoughlyEnoughItems-67fc756047f34bdbb9f028e48fc725534b3beafc.tar.bz2 RoughlyEnoughItems-67fc756047f34bdbb9f028e48fc725534b3beafc.zip | |
Merge pull request #86 from shedaniel/1.14-dev
REi v2.9 (WIP)
Diffstat (limited to 'src/main/java/com')
| -rw-r--r-- | src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java | 38 |
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 |
