From 0fe2df46206d12f2560806ffbef8674e1b3bec0b Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Fri, 25 Nov 2016 23:12:01 +0100
Subject: [PATCH] move GLFW init from Run to NewWindow

---
 run.go    | 10 +---------
 window.go |  2 ++
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/run.go b/run.go
index 50ae2a5..343b92b 100644
--- a/run.go
+++ b/run.go
@@ -3,7 +3,6 @@ package pixel
 import (
 	"github.com/faiface/pixel/pixelgl"
 	"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 limitations of OpenGL and operating systems,
@@ -24,14 +23,7 @@ import (
 //
 // You can spawn any number of goroutines from you run function and interact with Pixel concurrently.
 // The only condition is that the Run function must be called from your main function.
-func Run(run func()) error {
-	err := glfw.Init()
-	if err != nil {
-		return errors.Wrap(err, "failed to initialize GLFW")
-	}
+func Run(run func()) {
 	defer glfw.Terminate()
-
 	pixelgl.Run(run)
-
-	return nil
 }
diff --git a/window.go b/window.go
index 723c05d..7e23ecf 100644
--- a/window.go
+++ b/window.go
@@ -73,6 +73,8 @@ func NewWindow(config WindowConfig) (*Window, error) {
 	w := &Window{config: config}
 
 	err := pixelgl.DoErr(func() error {
+		glfw.Init()
+
 		glfw.WindowHint(glfw.ContextVersionMajor, 3)
 		glfw.WindowHint(glfw.ContextVersionMinor, 3)
 		glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
-- 
GitLab