mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
ui: Adjust window size in case when glfwGetVideoMode fails (#328)
This commit is contained in:
parent
71f427ecbc
commit
fb612a4b87
@ -194,6 +194,7 @@ func Run(width, height int, scale float64, title string, g GraphicsContext) erro
|
||||
w, h := u.glfwSize()
|
||||
x := (v.Width - w) / 2
|
||||
y := (v.Height - h) / 3
|
||||
x, y = adjustWindowPosition(x, y)
|
||||
u.window.SetPos(x, y)
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
@ -25,3 +25,7 @@ func deviceScale() float64 {
|
||||
func glfwScale() float64 {
|
||||
return deviceScale()
|
||||
}
|
||||
|
||||
func adjustWindowPosition(x, y int) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
@ -36,3 +36,7 @@ func deviceScale() float64 {
|
||||
func glfwScale() float64 {
|
||||
return 1
|
||||
}
|
||||
|
||||
func adjustWindowPosition(x, y int) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
@ -30,6 +30,11 @@ package ui
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
// static int getCaptionHeight() {
|
||||
// return GetSystemMetrics(SM_CYCAPTION);
|
||||
// }
|
||||
//
|
||||
import "C"
|
||||
|
||||
func deviceScale() float64 {
|
||||
@ -43,3 +48,16 @@ func deviceScale() float64 {
|
||||
func glfwScale() float64 {
|
||||
return deviceScale()
|
||||
}
|
||||
|
||||
func adjustWindowPosition(x, y int) (int, int) {
|
||||
// As the video width/height might be wrong,
|
||||
// adjust x/y at least to enable to handle the window (#328)
|
||||
if x < 0 {
|
||||
x = 0
|
||||
}
|
||||
t := int(C.getCaptionHeight())
|
||||
if y < t {
|
||||
y = t
|
||||
}
|
||||
return x, y
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user