game: fullscreen on F11

This commit is contained in:
Edgaru089 2022-01-26 23:31:40 +08:00
parent 13649fad18
commit d8df67bc20
2 changed files with 20 additions and 1 deletions

View File

@ -25,6 +25,8 @@ type Game struct {
rotZ float32 // Degrees in range (-90, 90) 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 io imgui.IO
gui guiState gui guiState

View File

@ -129,6 +129,23 @@ func (g *Game) Init(win *glfw.Window) {
win.SetCursorPos(float64(width)/2, float64(height)/2) 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
}
}
} }
}) })