From d8df67bc20916e6c601ee9f791d6b32773705f45 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Wed, 26 Jan 2022 23:31:40 +0800 Subject: [PATCH] game: fullscreen on F11 --- internal/game/game.go | 4 +++- internal/game/logic.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/internal/game/game.go b/internal/game/game.go index a0c1bd2..0a7408d 100644 --- a/internal/game/game.go +++ b/internal/game/game.go @@ -24,7 +24,9 @@ type Game struct { rotY itype.Angle rotZ float32 // Degrees in range (-90, 90) - fbSize itype.Vec2i + fbSize itype.Vec2i + fullscreen bool + lastPos, lastSize itype.Vec2i // Window size before entering fullscreen io imgui.IO gui guiState diff --git a/internal/game/logic.go b/internal/game/logic.go index a7f7edc..7cf27ea 100644 --- a/internal/game/logic.go +++ b/internal/game/logic.go @@ -129,6 +129,23 @@ func (g *Game) Init(win *glfw.Window) { win.SetCursorPos(float64(width)/2, float64(height)/2) } } + + if key == glfw.KeyF11 { + if g.fullscreen { + win.SetMonitor(nil, g.lastPos[0], g.lastPos[1], g.lastSize[0], g.lastSize[1], glfw.DontCare) + g.fullscreen = false + } else { + g.lastPos[0], g.lastPos[1] = win.GetPos() + g.lastSize[0], g.lastSize[1] = win.GetSize() + + monitor := glfw.GetPrimaryMonitor() + videoMode := monitor.GetVideoMode() + + win.SetMonitor(monitor, 0, 0, videoMode.Width, videoMode.Height, glfw.DontCare) + + g.fullscreen = true + } + } } })