mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
internal/devicescale: bug fix: glfw.Monitor.GetContentScale might return 0
Retrying to call GetContentScale solved this. Closes #2051
This commit is contained in:
parent
f1f9f74e5c
commit
f756be3d22
@ -35,6 +35,13 @@ func monitorAt(x, y int) *glfw.Monitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func impl(x, y int) float64 {
|
func impl(x, y int) float64 {
|
||||||
|
// Keep calling GetContentScale until the returned scale is 0 (#2051).
|
||||||
|
// Retry this at most 5 times to avoid an inifinite loop.
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
sx, _ := monitorAt(x, y).GetContentScale()
|
sx, _ := monitorAt(x, y).GetContentScale()
|
||||||
|
if sx != 0 {
|
||||||
return float64(sx)
|
return float64(sx)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user