From 1fb90c10c5cfaa5eefd193538f063e6856c1f1e2 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Sat, 26 Apr 2014 10:02:36 +0200 Subject: [PATCH] sick of clicking to close --- ld48-29.go | 20 ++++++++++++++++++-- log.mdown | 5 +++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ld48-29.go b/ld48-29.go index bce61fe..e3a0c8a 100644 --- a/ld48-29.go +++ b/ld48-29.go @@ -12,14 +12,28 @@ var _ = gl.Begin // TODO: remove later var _ = glfw.Init // TODO: remove later var _ = pa.Initialize // TODO: remove later -func errorCallback(err glfw.ErrorCode, desc string) { +func onError(err glfw.ErrorCode, desc string) { log.Printf("%v: %v\n", err, desc) } +func onKey(window *glfw.Window, k glfw.Key, s int, action glfw.Action, mods glfw.ModifierKey) { + if action != glfw.Press { + return + } + + switch glfw.Key(k) { + case glfw.KeyEscape: + window.SetShouldClose(true) + default: + return + } + +} + func main() { runtime.LockOSThread() - glfw.SetErrorCallback(errorCallback) + glfw.SetErrorCallback(onError) if !glfw.Init() { panic("Can't init glfw!") @@ -31,6 +45,8 @@ func main() { log.Panic(err) } + window.SetKeyCallback(onKey) + window.MakeContextCurrent() setup() diff --git a/log.mdown b/log.mdown index 3c76ab5..d3df0c6 100644 --- a/log.mdown +++ b/log.mdown @@ -28,3 +28,8 @@ All time is CEST Duh. Found via rubberducking I Was calling some stuff *before* MakeContextCurrent. 20min lost. + +- 09:57 + + Sideband idea: make this file post new LIs to Twitter on push (with link to + file+line on Github)