mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-10 06:14:38 +00:00
15 lines
685 B
TypeScript
15 lines
685 B
TypeScript
// Cap the effective devicePixelRatio used for the WebGL drawing buffer and
|
||
// any pixel-aware HUD math. Above 1.5×, low-end integrated GPU compositors
|
||
// (notably older Chromebooks) can't swap the drawing buffer within a vsync
|
||
// interval and frame pacing collapses. All callers must agree on this value
|
||
// or camera ↔ screen coordinate math will desync.
|
||
const MAX_RENDER_DPR = 1.5;
|
||
|
||
// BISECT: sub-native render scale to test whether fill rate is the bottleneck
|
||
// on low-end Chromebooks. 0.5 = 1/4 the pixels. Visibly softer.
|
||
const RENDER_SCALE = 0.5;
|
||
|
||
export function getEffectiveDpr(): number {
|
||
return Math.min(window.devicePixelRatio || 1, MAX_RENDER_DPR) * RENDER_SCALE;
|
||
}
|