diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-07-18 15:48:43 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-07-18 15:48:43 +0800 |
| commit | c78a022162a575e18e8ca8e18d92518c7cb6b2f8 (patch) | |
| tree | 1902b8943b618b4eceb05b563a78d4bebc9e1b26 /src/main/java/com | |
| parent | 0820200bb0f9f072782bbcf89add5c4cae0f5972 (diff) | |
| download | RoughlyEnoughItems-legacy/2.x-1.13.2-rift.tar.gz RoughlyEnoughItems-legacy/2.x-1.13.2-rift.tar.bz2 RoughlyEnoughItems-legacy/2.x-1.13.2-rift.zip | |
v2.10.0legacy/2.x-1.13.2-rift
Diffstat (limited to 'src/main/java/com')
| -rw-r--r-- | src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java | 52 |
1 files changed, 52 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..1693b316c --- /dev/null +++ b/src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java @@ -0,0 +1,52 @@ +package com.zeitheron.hammercore.client.utils; + +import net.minecraft.client.MainWindow; +import net.minecraft.client.Minecraft; +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 { + /** + * Starts the scissor test + */ + public static void begin() { + GL11.glEnable(GL11.GL_SCISSOR_TEST); + } + + /** + * Setup the scissor bounds + * + * @param x the top left x coordinates + * @param y the top left y coordinates + * @param width the width of the bounds + * @param height the height of the bounds + */ + public static void scissor(int x, int y, int width, int height) { + MainWindow window = Minecraft.getInstance().mainWindow; + + 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); + } + + /** + * Stops the scissor test + */ + public static void end() { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } +}
\ No newline at end of file |
