From 63c9ab68e2b623a07d29de4bb28057f6d9810fcd Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Sat, 3 Dec 2016 01:45:47 +0100
Subject: [PATCH] fix window context holder

---
 window.go | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/window.go b/window.go
index 597a8ca..eadc0da 100644
--- a/window.go
+++ b/window.go
@@ -55,6 +55,7 @@ type Window struct {
 	window        *glfw.Window
 	config        WindowConfig
 	contextHolder pixelgl.ContextHolder
+	defaultShader *pixelgl.Shader
 
 	// need to save these to correctly restore a fullscreen window
 	restore struct {
@@ -104,13 +105,13 @@ func NewWindow(config WindowConfig) (*Window, error) {
 
 	w.SetFullscreen(config.Fullscreen)
 
-	defaultShader, err := pixelgl.NewShader(w, defaultVertexFormat, defaultUniformFormat, defaultVertexShader, defaultFragmentShader)
+	defaultShader, err := pixelgl.NewShader(&w.contextHolder, defaultVertexFormat, defaultUniformFormat, defaultVertexShader, defaultFragmentShader)
 	if err != nil {
 		w.Delete()
 		return nil, errors.Wrap(err, "creating window failed")
 	}
 
-	w.contextHolder.Context = pixelgl.Context{}.WithShader(defaultShader)
+	w.defaultShader = defaultShader
 
 	return w, nil
 }
@@ -311,7 +312,11 @@ func (w *Window) Do(sub func(pixelgl.Context)) {
 		currentWindow.handler = w
 	}
 
-	w.contextHolder.Do(sub)
+	if w.defaultShader != nil {
+		w.defaultShader.Do(sub)
+	} else {
+		w.contextHolder.Do(sub)
+	}
 }
 
 var defaultVertexFormat = pixelgl.VertexFormat{
-- 
GitLab