0
0
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:
Alexander01998 2024-08-25 20:08:52 +02:00
parent 567cd930e8
commit e6177e7f67
7 changed files with 46 additions and 61 deletions

View File

@ -740,11 +740,7 @@ public final class ClickGui
bufferBuilder.vertex(matrix, x4, y3, 0); bufferBuilder.vertex(matrix, x4, y3, 0);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderSystem.setShaderColor(1, 1, 1, 1); RenderUtils.enableScissor(context, x1, y3, x2, y2);
context.enableScissor(x1, y3, x2, y2);
RenderSystem.setShader(ShaderProgramKeys.POSITION);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
matrixStack.push(); matrixStack.push();
matrixStack.translate(x1, y4, 0); matrixStack.translate(x1, y4, 0);
@ -796,7 +792,7 @@ public final class ClickGui
matrixStack.pop(); matrixStack.pop();
matrix = matrixStack.peek().getPositionMatrix(); matrix = matrixStack.peek().getPositionMatrix();
context.disableScissor(); RenderUtils.disableScissor(context);
} }
RenderSystem.enableBlend(); RenderSystem.enableBlend();

View File

@ -23,7 +23,6 @@ import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.wurstclient.Category; import net.wurstclient.Category;
import net.wurstclient.Feature; import net.wurstclient.Feature;
@ -130,27 +129,25 @@ public final class TabGui implements KeyPressListener
if(tabGuiOtf.isHidden()) if(tabGuiOtf.isHidden())
return; return;
// CURSED: TabGUI renders behind HackList without this
context.getVertexConsumers().draw();
ClickGui gui = WurstClient.INSTANCE.getGui(); ClickGui gui = WurstClient.INSTANCE.getGui();
int txtColor = gui.getTxtColor(); int txtColor = gui.getTxtColor();
GL11.glDisable(GL11.GL_CULL_FACE); RenderSystem.enableBlend();
GL11.glEnable(GL11.GL_BLEND); RenderSystem.defaultBlendFunc();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.disableCull();
matrixStack.push(); matrixStack.push();
Window sr = WurstClient.MC.getWindow();
int x = 2; int x = 2;
int y = 23; int y = 23;
matrixStack.translate(x, y, 0); matrixStack.translate(x, y, 100);
drawBox(matrixStack, 0, 0, width, height); drawBox(matrixStack, 0, 0, width, height);
double factor = sr.getScaleFactor(); RenderUtils.enableScissor(context, x, y, x + width, y + height);
GL11.glScissor((int)(x * factor),
(int)((sr.getScaledHeight() - height - y) * factor),
(int)(width * factor), (int)(height * factor));
GL11.glEnable(GL11.GL_SCISSOR_TEST);
int textY = 1; int textY = 1;
@ -164,8 +161,8 @@ public final class TabGui implements KeyPressListener
txtColor, false); txtColor, false);
textY += 10; textY += 10;
} }
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_SCISSOR_TEST); RenderUtils.disableScissor(context);
if(tabOpened) if(tabOpened)
{ {
@ -178,10 +175,8 @@ public final class TabGui implements KeyPressListener
matrixStack.translate(width + 2, 0, 0); matrixStack.translate(width + 2, 0, 0);
drawBox(matrixStack, 0, 0, tab.width, tab.height); drawBox(matrixStack, 0, 0, tab.width, tab.height);
GL11.glScissor((int)(tabX * factor), RenderUtils.enableScissor(context, tabX, tabY, tabX + tab.width,
(int)((sr.getScaledHeight() - tab.height - tabY) * factor), tabY + tab.height);
(int)(tab.width * factor), (int)(tab.height * factor));
GL11.glEnable(GL11.GL_SCISSOR_TEST);
int tabTextY = 1; int tabTextY = 1;
for(int i = 0; i < tab.features.size(); i++) for(int i = 0; i < tab.features.size(); i++)
@ -199,8 +194,8 @@ public final class TabGui implements KeyPressListener
tabTextY, txtColor, false); tabTextY, txtColor, false);
tabTextY += 10; tabTextY += 10;
} }
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_SCISSOR_TEST); RenderUtils.disableScissor(context);
matrixStack.pop(); matrixStack.pop();
} }

View File

@ -352,13 +352,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
bgx2, bgy2); bgx2, bgy2);
drawBoxShadow(matrixStack, bgx1, bgy1, bgx2, bgy2); drawBoxShadow(matrixStack, bgx1, bgy1, bgx2, bgy2);
// scissor box RenderUtils.enableScissor(context, bgx1, bgy1, bgx2, bgy3);
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);
// settings // settings
gui.setTooltip(""); gui.setTooltip("");
@ -498,10 +492,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
} }
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
// scissor box RenderUtils.disableScissor(context);
context.disableScissor();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
// buttons below scissor box // buttons below scissor box
for(ClickableWidget button : Screens.getButtons(this)) for(ClickableWidget button : Screens.getButtons(this))

View File

@ -254,8 +254,7 @@ public final class NavigatorMainScreen extends NavigatorScreen
if(!clickTimerRunning) if(!clickTimerRunning)
hoveredFeature = -1; hoveredFeature = -1;
RenderUtils.scissorBox(0, 59, width, height - 42); RenderUtils.enableScissor(context, 0, 59, width, height - 42);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
for(int i = Math.max(-scroll * 3 / 20 - 3, 0); i < navigatorDisplayList for(int i = Math.max(-scroll * 3 / 20 - 3, 0); i < navigatorDisplayList
.size(); i++) .size(); i++)
@ -272,7 +271,7 @@ public final class NavigatorMainScreen extends NavigatorScreen
featureY); featureY);
} }
GL11.glDisable(GL11.GL_SCISSOR_TEST); RenderUtils.disableScissor(context);
// tooltip // tooltip
if(tooltip != null) if(tooltip != null)

View File

@ -176,9 +176,7 @@ public class NavigatorNewKeybindScreen extends NavigatorScreen
boolean noButtons = Screens.getButtons(this).isEmpty(); boolean noButtons = Screens.getButtons(this).isEmpty();
int bgy3 = bgy2 - (noButtons ? 0 : 24); int bgy3 = bgy2 - (noButtons ? 0 : 24);
// scissor box RenderUtils.enableScissor(context, bgx1, bgy1, bgx2, bgy3);
RenderUtils.scissorBox(bgx1, bgy1, bgx2, bgy3);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
// possible keybinds // possible keybinds
if(!choosingKey) if(!choosingKey)
@ -233,8 +231,7 @@ public class NavigatorNewKeybindScreen extends NavigatorScreen
} }
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
// scissor box RenderUtils.disableScissor(context);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
// buttons below scissor box // buttons below scissor box
for(ClickableWidget button : Screens.getButtons(this)) for(ClickableWidget button : Screens.getButtons(this))

View File

@ -148,9 +148,7 @@ public class NavigatorRemoveKeybindScreen extends NavigatorScreen
boolean noButtons = Screens.getButtons(this).isEmpty(); boolean noButtons = Screens.getButtons(this).isEmpty();
int bgy3 = bgy2 - (noButtons ? 0 : 24); int bgy3 = bgy2 - (noButtons ? 0 : 24);
// scissor box RenderUtils.enableScissor(context, bgx1, bgy1, bgx2, bgy3);
RenderUtils.scissorBox(bgx1, bgy1, bgx2, bgy3);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
// possible keybinds // possible keybinds
hoveredKey = ""; hoveredKey = "";
@ -204,8 +202,7 @@ public class NavigatorRemoveKeybindScreen extends NavigatorScreen
} }
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
// scissor box RenderUtils.disableScissor(context);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
// buttons below scissor box // buttons below scissor box
for(ClickableWidget button : Screens.getButtons(this)) for(ClickableWidget button : Screens.getButtons(this))

View File

@ -9,7 +9,6 @@ package net.wurstclient.util;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.systems.RenderSystem; 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); 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; RenderSystem.setShaderColor(1, 1, 1, 1);
int height = endY - startY; context.enableScissor(x1, y1, x2, y2);
int bottomY = WurstClient.MC.currentScreen.height - endY; RenderSystem.setShader(ShaderProgramKeys.POSITION);
double factor = WurstClient.MC.getWindow().getScaleFactor(); RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
int scissorX = (int)(startX * factor); }
int scissorY = (int)(bottomY * factor);
int scissorWidth = (int)(width * factor); /**
int scissorHeight = (int)(height * factor); * Disables the current scissor box, while avoiding the strange side-effects
GL11.glScissor(scissorX, scissorY, scissorWidth, scissorHeight); * of Minecraft's own disableScissor() method.
*/
public static void disableScissor(DrawContext context)
{
context.disableScissor();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
} }
public static void applyRegionalRenderOffset(MatrixStack matrixStack) public static void applyRegionalRenderOffset(MatrixStack matrixStack)