this should've been with prev commit

This commit is contained in:
faiface 2017-01-26 03:33:48 +01:00
parent 19faeffcf1
commit b141bcbd50
1 changed files with 5 additions and 0 deletions

5
run.go
View File

@ -3,6 +3,7 @@ package pixel
import ( import (
"github.com/faiface/mainthread" "github.com/faiface/mainthread"
"github.com/go-gl/glfw/v3.2/glfw" "github.com/go-gl/glfw/v3.2/glfw"
"github.com/pkg/errors"
) )
// Run is essentialy the "main" function of Pixel. It exists mainly due to the technical // Run is essentialy the "main" function of Pixel. It exists mainly due to the technical
@ -27,6 +28,10 @@ import (
// concurrently. The only condition is that the Run function is be called from your main // concurrently. The only condition is that the Run function is be called from your main
// function. // function.
func Run(run func()) { func Run(run func()) {
err := glfw.Init()
if err != nil {
panic(errors.Wrap(err, "failed to initialize GLFW"))
}
defer glfw.Terminate() defer glfw.Terminate()
mainthread.Run(run) mainthread.Run(run)
} }