From faaa8530a350e6d719092f0a13d7f8d6ee6fe331 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 11 Dec 2019 12:31:03 -0500 Subject: [PATCH] v0.8.0: fixed errors in glScissor operations on macOS --- .../main/java/com/watabou/noosa/NoosaScript.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java b/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java index d0b90758e..829750dfe 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java @@ -161,11 +161,18 @@ public class NoosaScript extends Script { if (!camera.fullScreen) { Gdx.gl20.glEnable( Gdx.gl20.GL_SCISSOR_TEST ); + + //This fixes pixel scaling issues on some hidpi displays (mainly on macOS) + // because for some reason all other openGL operations work on virtual pixels + // but glScissor operations work on real pixels + float xScale = (Gdx.graphics.getBackBufferWidth() / (float)Game.width ); + float yScale = (Gdx.graphics.getBackBufferHeight() / (float)Game.height ); + Gdx.gl20.glScissor( - camera.x, - Game.height - camera.screenHeight - camera.y, - camera.screenWidth, - camera.screenHeight); + Math.round(camera.x * xScale), + Math.round((Game.height - camera.screenHeight - camera.y) * yScale), + Math.round(camera.screenWidth * xScale), + Math.round(camera.screenHeight * yScale)); } else { Gdx.gl20.glDisable( Gdx.gl20.GL_SCISSOR_TEST ); }