Fix scissor test being enabled while no area is set

This commit is contained in:
johni0702
2015-11-08 08:59:35 +01:00
parent b2a9496d8f
commit 491ab013f1
2 changed files with 11 additions and 3 deletions

View File

@@ -92,7 +92,10 @@ public class OffsetGuiRenderer implements GuiRenderer {
@Override
public void setDrawingArea(int x, int y, int width, int height) {
if (!strict) return;
if (!strict) {
renderer.setDrawingArea(x + position.getX(), y + position.getY(), width, height);
return;
}
int x2 = x + width;
int y2 = y + height;
// Convert and clamp top and left border
@@ -111,7 +114,7 @@ public class OffsetGuiRenderer implements GuiRenderer {
public void startUsing() {
GL11.glPushAttrib(GL11.GL_SCISSOR_BIT);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
setDrawingArea(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
setDrawingArea(0, 0, size.getWidth(), size.getHeight());
}
public void stopUsing() {

View File

@@ -112,7 +112,12 @@ public abstract class AbstractGuiDropdownMenu<V, T extends AbstractGuiDropdownMe
ReadablePoint offsetPoint = new Point(0, size.getHeight());
ReadableDimension offsetSize = new Dimension(size.getWidth(), (fontRenderer.FONT_HEIGHT + 5) * values.length);
OffsetGuiRenderer offsetRenderer = new OffsetGuiRenderer(renderer, offsetPoint, offsetSize);
dropdown.draw(offsetRenderer, offsetSize, renderInfo.offsetMouse(0, offsetPoint.getY()).layer(0));
offsetRenderer.startUsing();
try {
dropdown.draw(offsetRenderer, offsetSize, renderInfo.offsetMouse(0, offsetPoint.getY()).layer(0));
} finally {
offsetRenderer.stopUsing();
}
}
}