mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-19 17:02:13 +02:00
Fix remaining scissor box issues
This commit is contained in:
parent
567cd930e8
commit
e6177e7f67
@ -740,11 +740,7 @@ public final class ClickGui
|
||||
bufferBuilder.vertex(matrix, x4, y3, 0);
|
||||
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
|
||||
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
context.enableScissor(x1, y3, x2, y2);
|
||||
RenderSystem.setShader(ShaderProgramKeys.POSITION);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderUtils.enableScissor(context, x1, y3, x2, y2);
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.translate(x1, y4, 0);
|
||||
@ -796,7 +792,7 @@ public final class ClickGui
|
||||
|
||||
matrixStack.pop();
|
||||
matrix = matrixStack.peek().getPositionMatrix();
|
||||
context.disableScissor();
|
||||
RenderUtils.disableScissor(context);
|
||||
}
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
|
@ -23,7 +23,6 @@ import net.minecraft.client.render.BufferRenderer;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.util.Window;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.wurstclient.Category;
|
||||
import net.wurstclient.Feature;
|
||||
@ -130,27 +129,25 @@ public final class TabGui implements KeyPressListener
|
||||
if(tabGuiOtf.isHidden())
|
||||
return;
|
||||
|
||||
// CURSED: TabGUI renders behind HackList without this
|
||||
context.getVertexConsumers().draw();
|
||||
|
||||
ClickGui gui = WurstClient.INSTANCE.getGui();
|
||||
int txtColor = gui.getTxtColor();
|
||||
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.disableCull();
|
||||
|
||||
matrixStack.push();
|
||||
Window sr = WurstClient.MC.getWindow();
|
||||
|
||||
int x = 2;
|
||||
int y = 23;
|
||||
|
||||
matrixStack.translate(x, y, 0);
|
||||
matrixStack.translate(x, y, 100);
|
||||
drawBox(matrixStack, 0, 0, width, height);
|
||||
|
||||
double factor = sr.getScaleFactor();
|
||||
GL11.glScissor((int)(x * factor),
|
||||
(int)((sr.getScaledHeight() - height - y) * factor),
|
||||
(int)(width * factor), (int)(height * factor));
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.enableScissor(context, x, y, x + width, y + height);
|
||||
|
||||
int textY = 1;
|
||||
|
||||
@ -164,8 +161,8 @@ public final class TabGui implements KeyPressListener
|
||||
txtColor, false);
|
||||
textY += 10;
|
||||
}
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
|
||||
RenderUtils.disableScissor(context);
|
||||
|
||||
if(tabOpened)
|
||||
{
|
||||
@ -178,10 +175,8 @@ public final class TabGui implements KeyPressListener
|
||||
matrixStack.translate(width + 2, 0, 0);
|
||||
drawBox(matrixStack, 0, 0, tab.width, tab.height);
|
||||
|
||||
GL11.glScissor((int)(tabX * factor),
|
||||
(int)((sr.getScaledHeight() - tab.height - tabY) * factor),
|
||||
(int)(tab.width * factor), (int)(tab.height * factor));
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.enableScissor(context, tabX, tabY, tabX + tab.width,
|
||||
tabY + tab.height);
|
||||
|
||||
int tabTextY = 1;
|
||||
for(int i = 0; i < tab.features.size(); i++)
|
||||
@ -199,8 +194,8 @@ public final class TabGui implements KeyPressListener
|
||||
tabTextY, txtColor, false);
|
||||
tabTextY += 10;
|
||||
}
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
|
||||
RenderUtils.disableScissor(context);
|
||||
|
||||
matrixStack.pop();
|
||||
}
|
||||
|
@ -352,13 +352,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
bgx2, bgy2);
|
||||
drawBoxShadow(matrixStack, bgx1, bgy1, bgx2, bgy2);
|
||||
|
||||
// scissor box
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
context.enableScissor(bgx1, bgy1, bgx2, bgy3);
|
||||
RenderSystem.setShader(ShaderProgramKeys.POSITION);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.enableScissor(context, bgx1, bgy1, bgx2, bgy3);
|
||||
|
||||
// settings
|
||||
gui.setTooltip("");
|
||||
@ -498,10 +492,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
}
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
// scissor box
|
||||
context.disableScissor();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderUtils.disableScissor(context);
|
||||
|
||||
// buttons below scissor box
|
||||
for(ClickableWidget button : Screens.getButtons(this))
|
||||
|
@ -254,8 +254,7 @@ public final class NavigatorMainScreen extends NavigatorScreen
|
||||
if(!clickTimerRunning)
|
||||
hoveredFeature = -1;
|
||||
|
||||
RenderUtils.scissorBox(0, 59, width, height - 42);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.enableScissor(context, 0, 59, width, height - 42);
|
||||
|
||||
for(int i = Math.max(-scroll * 3 / 20 - 3, 0); i < navigatorDisplayList
|
||||
.size(); i++)
|
||||
@ -272,7 +271,7 @@ public final class NavigatorMainScreen extends NavigatorScreen
|
||||
featureY);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.disableScissor(context);
|
||||
|
||||
// tooltip
|
||||
if(tooltip != null)
|
||||
|
@ -176,9 +176,7 @@ public class NavigatorNewKeybindScreen extends NavigatorScreen
|
||||
boolean noButtons = Screens.getButtons(this).isEmpty();
|
||||
int bgy3 = bgy2 - (noButtons ? 0 : 24);
|
||||
|
||||
// scissor box
|
||||
RenderUtils.scissorBox(bgx1, bgy1, bgx2, bgy3);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.enableScissor(context, bgx1, bgy1, bgx2, bgy3);
|
||||
|
||||
// possible keybinds
|
||||
if(!choosingKey)
|
||||
@ -233,8 +231,7 @@ public class NavigatorNewKeybindScreen extends NavigatorScreen
|
||||
}
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
// scissor box
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.disableScissor(context);
|
||||
|
||||
// buttons below scissor box
|
||||
for(ClickableWidget button : Screens.getButtons(this))
|
||||
|
@ -148,9 +148,7 @@ public class NavigatorRemoveKeybindScreen extends NavigatorScreen
|
||||
boolean noButtons = Screens.getButtons(this).isEmpty();
|
||||
int bgy3 = bgy2 - (noButtons ? 0 : 24);
|
||||
|
||||
// scissor box
|
||||
RenderUtils.scissorBox(bgx1, bgy1, bgx2, bgy3);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.enableScissor(context, bgx1, bgy1, bgx2, bgy3);
|
||||
|
||||
// possible keybinds
|
||||
hoveredKey = "";
|
||||
@ -204,8 +202,7 @@ public class NavigatorRemoveKeybindScreen extends NavigatorScreen
|
||||
}
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
// scissor box
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
RenderUtils.disableScissor(context);
|
||||
|
||||
// buttons below scissor box
|
||||
for(ClickableWidget button : Screens.getButtons(this))
|
||||
|
@ -9,7 +9,6 @@ package net.wurstclient.util;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
@ -34,18 +33,29 @@ public enum RenderUtils
|
||||
|
||||
private static final Box DEFAULT_BOX = new Box(0, 0, 0, 1, 1, 1);
|
||||
|
||||
public static void scissorBox(int startX, int startY, int endX, int endY)
|
||||
/**
|
||||
* Enables a new scissor box with the given coordinates, while avoiding the
|
||||
* strange side-effects of Minecraft's own enableScissor() method.
|
||||
*/
|
||||
public static void enableScissor(DrawContext context, int x1, int y1,
|
||||
int x2, int y2)
|
||||
{
|
||||
int width = endX - startX;
|
||||
int height = endY - startY;
|
||||
int bottomY = WurstClient.MC.currentScreen.height - endY;
|
||||
double factor = WurstClient.MC.getWindow().getScaleFactor();
|
||||
|
||||
int scissorX = (int)(startX * factor);
|
||||
int scissorY = (int)(bottomY * factor);
|
||||
int scissorWidth = (int)(width * factor);
|
||||
int scissorHeight = (int)(height * factor);
|
||||
GL11.glScissor(scissorX, scissorY, scissorWidth, scissorHeight);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
context.enableScissor(x1, y1, x2, y2);
|
||||
RenderSystem.setShader(ShaderProgramKeys.POSITION);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the current scissor box, while avoiding the strange side-effects
|
||||
* of Minecraft's own disableScissor() method.
|
||||
*/
|
||||
public static void disableScissor(DrawContext context)
|
||||
{
|
||||
context.disableScissor();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
}
|
||||
|
||||
public static void applyRegionalRenderOffset(MatrixStack matrixStack)
|
||||
|
Loading…
Reference in New Issue
Block a user