mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Bug fix: DeviceScaleFactor should return the current monitor's scale
This commit is contained in:
parent
16a9bac487
commit
f3b7148564
@ -22,10 +22,6 @@ var (
|
|||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
func Get() float64 {
|
|
||||||
return GetAt(0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAt(x, y int) float64 {
|
func GetAt(x, y int) float64 {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
|
@ -495,6 +495,21 @@ func SetWindowDecorated(decorated bool) {
|
|||||||
// return nil
|
// return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeviceScaleFactor() float64 {
|
||||||
|
f := 0.0
|
||||||
|
u := currentUI
|
||||||
|
if !u.isRunning() {
|
||||||
|
return devicescale.GetAt(currentMonitor().GetPos())
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = u.runOnMainThread(func() error {
|
||||||
|
m := u.currentMonitor()
|
||||||
|
f = devicescale.GetAt(m.GetPos())
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool) error {
|
func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool) error {
|
||||||
u := currentUI
|
u := currentUI
|
||||||
// GLContext must be created before setting the screen size, which requires
|
// GLContext must be created before setting the screen size, which requires
|
||||||
|
@ -84,7 +84,7 @@ func getDeviceScale() float64 {
|
|||||||
defer deviceScaleM.Unlock()
|
defer deviceScaleM.Unlock()
|
||||||
|
|
||||||
if deviceScaleVal == 0 {
|
if deviceScaleVal == 0 {
|
||||||
deviceScaleVal = devicescale.Get()
|
deviceScaleVal = devicescale.GetAt(0, 0)
|
||||||
}
|
}
|
||||||
return deviceScaleVal
|
return deviceScaleVal
|
||||||
}
|
}
|
||||||
|
3
run.go
3
run.go
@ -23,7 +23,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/png"
|
"github.com/hajimehoshi/ebiten/internal/png"
|
||||||
"github.com/hajimehoshi/ebiten/internal/shareable"
|
"github.com/hajimehoshi/ebiten/internal/shareable"
|
||||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||||
@ -528,7 +527,7 @@ func SetWindowIcon(iconImages []image.Image) {
|
|||||||
//
|
//
|
||||||
// DeviceScaleFactor is concurrent-safe.
|
// DeviceScaleFactor is concurrent-safe.
|
||||||
func DeviceScaleFactor() float64 {
|
func DeviceScaleFactor() float64 {
|
||||||
return devicescale.Get()
|
return ui.DeviceScaleFactor()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsVsyncEnabled returns a boolean value indicating whether
|
// IsVsyncEnabled returns a boolean value indicating whether
|
||||||
|
Loading…
Reference in New Issue
Block a user