Skip to content

Instantly share code, notes, and snippets.

@james4k
Last active December 24, 2015 12:59
Show Gist options
  • Save james4k/6801003 to your computer and use it in GitHub Desktop.
Save james4k/6801003 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
glfw "github.com/go-gl/glfw3"
)
func errorCallback(err glfw.ErrorCode, desc string) {
fmt.Printf("%v: %v\n", err, desc)
}
func onCloseA(wnd *glfw.Window) {
fmt.Println("closed A")
}
func onCloseB(wnd *glfw.Window) {
fmt.Println("closed B")
}
func main() {
glfw.SetErrorCallback(errorCallback)
if !glfw.Init() {
panic("Can't init glfw!")
}
defer glfw.Terminate()
window, err := glfw.CreateWindow(640, 480, "Testing A", nil, nil)
if err != nil {
panic(err)
}
windowB, err := glfw.CreateWindow(640, 480, "Testing B", nil, nil)
if err != nil {
panic(err)
}
window.SetCloseCallback(onCloseA)
windowB.SetCloseCallback(onCloseB)
window.MakeContextCurrent()
for !window.ShouldClose() || !windowB.ShouldClose() {
//Do OpenGL stuff
window.SwapBuffers()
glfw.PollEvents()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment