mirror of
https://github.com/lloeki/ld48-29.git
synced 2025-12-06 02:54:40 +01:00
sick of clicking to close
This commit is contained in:
parent
40a2d5346f
commit
1fb90c10c5
2 changed files with 23 additions and 2 deletions
20
ld48-29.go
20
ld48-29.go
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue