mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
ui: Adjust fullscreen scale (#267)
This commit is contained in:
parent
5dbfafb200
commit
e7370d8a54
@ -30,19 +30,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type userInterface struct {
|
type userInterface struct {
|
||||||
window *glfw.Window
|
window *glfw.Window
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
scale float64
|
scale float64
|
||||||
deviceScale float64
|
deviceScale float64
|
||||||
glfwScale float64
|
glfwScale float64
|
||||||
fullscreen bool
|
fullscreen bool
|
||||||
funcs chan func()
|
fullscreenScale float64
|
||||||
running bool
|
funcs chan func()
|
||||||
sizeChanged bool
|
running bool
|
||||||
origPosX int
|
sizeChanged bool
|
||||||
origPosY int
|
origPosX int
|
||||||
m sync.Mutex
|
origPosY int
|
||||||
|
m sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentUI *userInterface
|
var currentUI *userInterface
|
||||||
@ -243,6 +244,20 @@ func (u *userInterface) actualScreenScale() float64 {
|
|||||||
if u.deviceScale == 0 {
|
if u.deviceScale == 0 {
|
||||||
u.deviceScale = deviceScale()
|
u.deviceScale = deviceScale()
|
||||||
}
|
}
|
||||||
|
if u.fullscreen {
|
||||||
|
if u.fullscreenScale == 0 {
|
||||||
|
m := glfw.GetPrimaryMonitor()
|
||||||
|
v := m.GetVideoMode()
|
||||||
|
sw := float64(v.Width) / float64(u.width)
|
||||||
|
sh := float64(v.Height) / float64(u.height)
|
||||||
|
s := sw
|
||||||
|
if s > sh {
|
||||||
|
s = sh
|
||||||
|
}
|
||||||
|
u.fullscreenScale = s
|
||||||
|
}
|
||||||
|
return u.fullscreenScale * u.deviceScale
|
||||||
|
}
|
||||||
return u.scale * u.deviceScale
|
return u.scale * u.deviceScale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user