v0.8.0: fixed errors in glScissor operations on macOS

This commit is contained in:
Evan Debenham 2019-12-11 12:31:03 -05:00
parent bd738bc0f8
commit faaa8530a3

View File

@ -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 );
}