sick of clicking to close

This commit is contained in:
Loic Nageleisen 2014-04-26 10:02:36 +02:00
parent 40a2d5346f
commit 1fb90c10c5
2 changed files with 23 additions and 2 deletions

View file

@ -12,14 +12,28 @@ var _ = gl.Begin // TODO: remove later
var _ = glfw.Init // TODO: remove later var _ = glfw.Init // TODO: remove later
var _ = pa.Initialize // 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) 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() { func main() {
runtime.LockOSThread() runtime.LockOSThread()
glfw.SetErrorCallback(errorCallback) glfw.SetErrorCallback(onError)
if !glfw.Init() { if !glfw.Init() {
panic("Can't init glfw!") panic("Can't init glfw!")
@ -31,6 +45,8 @@ func main() {
log.Panic(err) log.Panic(err)
} }
window.SetKeyCallback(onKey)
window.MakeContextCurrent() window.MakeContextCurrent()
setup() setup()

View file

@ -28,3 +28,8 @@ All time is CEST
Duh. Found via rubberducking I Was calling some stuff *before* Duh. Found via rubberducking I Was calling some stuff *before*
MakeContextCurrent. 20min lost. MakeContextCurrent. 20min lost.
- 09:57
Sideband idea: make this file post new LIs to Twitter on push (with link to
file+line on Github)