mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
ui: Keep the device scale to avoid re-calculation
This commit is contained in:
parent
d6219e38d8
commit
93cdfe107e
@ -34,6 +34,7 @@ type userInterface struct {
|
|||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
scale float64
|
scale float64
|
||||||
|
deviceScale float64
|
||||||
funcs chan func()
|
funcs chan func()
|
||||||
running bool
|
running bool
|
||||||
sizeChanged bool
|
sizeChanged bool
|
||||||
@ -208,7 +209,10 @@ func (u *userInterface) glfwSize() (int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) actualScreenScale() float64 {
|
func (u *userInterface) actualScreenScale() float64 {
|
||||||
return u.scale * deviceScale()
|
if u.deviceScale == 0 {
|
||||||
|
u.deviceScale = deviceScale()
|
||||||
|
}
|
||||||
|
return u.scale * u.deviceScale
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) pollEvents() {
|
func (u *userInterface) pollEvents() {
|
||||||
|
@ -34,7 +34,6 @@ package ui
|
|||||||
// static int getCaptionHeight() {
|
// static int getCaptionHeight() {
|
||||||
// return GetSystemMetrics(SM_CYCAPTION);
|
// return GetSystemMetrics(SM_CYCAPTION);
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
func deviceScale() float64 {
|
func deviceScale() float64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user