v3.2.2: moved pixel scale getters to deviceCompat

This commit is contained in:
Evan Debenham
2025-08-22 11:21:09 -04:00
parent 22fb116254
commit 701498a8e8
3 changed files with 15 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ import com.watabou.glwrap.Attribute;
import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Uniform;
import com.watabou.glwrap.Vertexbuffer;
import com.watabou.utils.DeviceCompat;
import java.nio.Buffer;
import java.nio.FloatBuffer;
@@ -166,8 +167,8 @@ public class NoosaScript extends Script {
//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()-Game.bottomInset) / (float)Game.height );
float xScale = DeviceCompat.getRealPixelScaleX();
float yScale = DeviceCompat.getRealPixelScaleY();
Gdx.gl20.glScissor(
Math.round(camera.x * xScale),

View File

@@ -67,4 +67,15 @@ public class DeviceCompat {
return result;
}
//some devices (macOS mainly) report virtual pixels to Shattered, but sometimes we want real pixel precision
//this returns the number of real pixels per virtual pixel in the X dimension...
public static float getRealPixelScaleX(){
return (Gdx.graphics.getBackBufferWidth() / (float)Game.width );
}
//...and in the Y dimension
public static float getRealPixelScaleY(){
return ((Gdx.graphics.getBackBufferHeight()-Game.bottomInset) / (float)Game.height );
}
}