func Zoom(zoom int) WindowOption {
	return func(window *Window) {
		if zoom > 0 {
			window.zoom = zoom
		}
	}
}
Zoom makes window/pixels bigger zoom times. For zoom <= 0, the zoom defaults to 1.
package glfw
import (
	"time"
	gl33 "github.com/go-gl/gl/v3.3-core/gl"
	"github.com/go-gl/glfw/v3.3/glfw"
	"github.com/jacekolszak/pixiq/gl"
	"github.com/jacekolszak/pixiq/goimage"
	"github.com/jacekolszak/pixiq/image"
)
func NewOpenGL(mainThreadLoop *MainThreadLoop) (*OpenGL, error) {
	if mainThreadLoop == nil {
		panic("nil MainThreadLoop")
	}
	var (
		mainWindow *glfw.Window
		err        error
	)
	mainThreadLoop.Execute(func() {
		err = glfw.Init()
		if err != nil {
			return
		}
		mainWindow, err = createWindow(mainThreadLoop, "OpenGL Pixiq Window", nil)
	})
	if err != nil {
		return nil, err
	}
	runInOpenGLThread := func(job func()) {
		mainThreadLoop.Execute(func() {
			mainThreadLoop.bind(mainWindow)
			job()
		})
	}
	openGL := &OpenGL{
		mainThreadLoop:    mainThreadLoop,
		runInOpenGLThread: runInOpenGLThread,
		stopPollingEvents: make(chan struct{}),
		mainWindow:        mainWindow,
		context:           gl.NewContext(newContext(mainThreadLoop, mainWindow)),
	}
	go openGL.startPollingEvents(openGL.stopPollingEvents)
	return openGL, nil
}
func RunOrDie(main func(gl *OpenGL)) {
	StartMainThreadLoop(func(mainThreadLoop *MainThreadLoop) {
		openGL, err := NewOpenGL(mainThreadLoop)
		if err != nil {
			panic(err)
		}
		defer openGL.Destroy()
		main(openGL)
	})
}
func createWindow(mainThreadLoop *MainThreadLoop, title string, share *glfw.Window) (*glfw.Window, error) {
	glfw.WindowHint(glfw.ContextVersionMajor, 3)
	glfw.WindowHint(glfw.ContextVersionMinor, 3)
	glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
	glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
	glfw.WindowHint(glfw.Resizable, glfw.False)
	glfw.WindowHint(glfw.Visible, glfw.False)
	glfw.WindowHint(glfw.CocoaRetinaFramebuffer, glfw.False)
	win, err := glfw.CreateWindow(3, 3, title, nil, share)
	if err != nil {
		return nil, err
	}
	mainThreadLoop.bind(win)
	if err := gl33.Init(); err != nil {
		return nil, err
	}
	return win, nil
}
type OpenGL struct {
	mainThreadLoop    *MainThreadLoop
	runInOpenGLThread func(func())
	stopPollingEvents chan struct{}
	mainWindow        *glfw.Window
	context           *gl.Context
	windowsOpen       int
}
func (g *OpenGL) Destroy() {
	g.stopPollingEvents <- struct{}{}
	g.runInOpenGLThread(func() {
		g.mainWindow.Destroy()
	})
}
func (g *OpenGL) startPollingEvents(stop <-chan struct{}) {
	ticker := time.NewTicker(4 * time.Millisecond)  
	for {
		<-ticker.C
		select {
		case <-stop:
			return
		default:
			g.mainThreadLoop.Execute(glfw.PollEvents)
		}
	}
}
func (g *OpenGL) NewImage(width, height int) *image.Image {
	if width < 0 {
		panic("negative width")
	}
	if height < 0 {
		panic("negative height")
	}
	acceleratedImage := g.context.NewAcceleratedImage(width, height)
	return image.New(acceleratedImage)
}
type mouseWindow struct {
	glfwWindow *glfw.Window
	zoom       int
}
func (m *mouseWindow) CursorPosition() (float64, float64) {
	return m.glfwWindow.GetCursorPos()
}
func (m *mouseWindow) Size() (int, int) {
	return m.glfwWindow.GetSize()
}
func (m *mouseWindow) Zoom() int {
	return m.zoom
}
func (g *OpenGL) OpenWindow(width, height int, options ...WindowOption) (*Window, error) {
	glfwWindow := g.mainWindow
	winContext := g.context
	if g.windowsOpen > 0 {
		var err error
		g.mainThreadLoop.Execute(func() {
			glfwWindow, err = createWindow(g.mainThreadLoop, "OpenGL Pixiq Window", g.mainWindow)
		})
		if err != nil {
			return nil, err
		}
		api := newContext(g.mainThreadLoop, glfwWindow)
		winContext = gl.NewContext(api)
	}
	onClose := func(window *Window) {
		if glfwWindow != g.mainWindow {
			g.mainThreadLoop.Execute(glfwWindow.Destroy)
		}
		g.windowsOpen--
	}
	win, err := newWindow(glfwWindow, g.mainThreadLoop, width, height, winContext, g.context, onClose, options)
	if err != nil {
		return nil, err
	}
	g.windowsOpen++
	return win, nil
}
func (g *OpenGL) Context() *gl.Context {
	return g.context
}
func (g *OpenGL) ContextAPI() gl.API {
	return g.context.API()
}
type WindowOption func(window *Window)
func NoDecorationHint() WindowOption {
	return func(win *Window) {
		win.glfwWindow.SetAttrib(glfw.Decorated, glfw.False)
	}
}
func Title(title string) WindowOption {
	return func(window *Window) {
		window.title = title
		window.glfwWindow.SetTitle(title)
	}
}