diff --git a/assets/scripts/zenity-help.bash b/assets/scripts/zenity-help.bash index edce155..4df0a40 100755 --- a/assets/scripts/zenity-help.bash +++ b/assets/scripts/zenity-help.bash @@ -46,6 +46,8 @@ Key press actions: Q - display your score and the number of remaining tokens S - toggle SKYBOX ON/OFF N - new SKYBOX + Shift+Q - quit + F11 - toggle full-screen OR USE THE GAMEPAD: diff --git a/game.go b/game.go index a8e715c..8ccf72f 100644 --- a/game.go +++ b/game.go @@ -35,7 +35,14 @@ const skyboxChance = 0.25 // the chance of having withSkybox==true on the new st // data structure for the game type Mki3dGame struct { + // Quit the game Quit bool + + // is full screen mode? + FullScreen bool + // Saved position and size of non-fullscreen window + PosX, PosY int + SizeWidth, SizeHeight int // assets info AssetsPtr *Assets // GLFW data diff --git a/help.go b/help.go index 08bfff6..5319a5d 100644 --- a/help.go +++ b/help.go @@ -46,6 +46,8 @@ Key press actions: Q - display your score and the number of remaining tokens S - toggle SKYBOX ON/OFF N - new SKYBOX + Shift+Q - quit + F11 - toggle full-screen OR USE THE GAMEPAD: diff --git a/key-callback.go b/key-callback.go index 69a6598..9bb6514 100644 --- a/key-callback.go +++ b/key-callback.go @@ -119,6 +119,23 @@ func (g *Mki3dGame) KeyCallback(w *glfw.Window, key glfw.Key, scancode int, acti g.Skybox.RenderRandomCube() g.withSkybox = true + case key == glfw.KeyF11: /* toggle full-screen */ + if !g.FullScreen { + /// set full-screen + g.PosX, g.PosY = w.GetPos() + g.SizeWidth, g.SizeHeight = w.GetSize() + monitor := glfw.GetPrimaryMonitor() + mode := monitor.GetVideoMode() + w.SetMonitor(monitor, 0, 0, mode.Width, mode.Height, mode.RefreshRate) + g.FullScreen = true + } else { + // unset full-screen + monitor := glfw.GetPrimaryMonitor() + mode := monitor.GetVideoMode() + w.SetMonitor(nil, g.PosX, g.PosY, g.SizeWidth, g.SizeHeight, mode.RefreshRate) + g.FullScreen = false + } + } } } diff --git a/main.go b/main.go index eff2e48..0f96568 100644 --- a/main.go +++ b/main.go @@ -169,9 +169,9 @@ func main() { glfw.SwapInterval(1) // try to avoid tearing ??? // game.CheckGamepad() // test + // main loop for !window.ShouldClose() && !game.Quit { - // Maintenance window.SwapBuffers() if doInMainThread != nil {