func Run(loop GameLoop) (err error) {
	defer func() {
		internal.Running = false
		internal.QuitRequested = false
		derr := internal.PolyCleanup()
		if err == nil && derr != nil {
			err = internal.Wrap("poly cleanup", derr)
			return
		}
		derr = internal.PixelCleanup()
		if err == nil && derr != nil {
			err = internal.Wrap("pixel cleanup", derr)
			return
		}
		derr = internal.InputCleanup()
		if err == nil && derr != nil {
			err = internal.Wrap("input cleanup", derr)
			return
		}
		derr = internal.GLCleanup()
		if err == nil && derr != nil {
			err = internal.Wrap("gl cleanup", derr)
			return
		}
		derr = internal.Cleanup()
		if err == nil && derr != nil {
			err = internal.Wrap("internal cleanup", derr)
			return
		}
	}()
	if internal.Running {
		return nil
	}
	internal.Loop = loop
	err = internal.Setup()
	if err != nil {
		return internal.Wrap("internal setup", err)
	}
	err = internal.GLSetup()
	if err != nil {
		return internal.Wrap("gl setup", err)
	}
	err = internal.InputSetup()
	if err != nil {
		return internal.Wrap("input setup", err)
	}
	err = internal.PixelSetup()
	if err != nil {
		return internal.Wrap("pixel setup", err)
	}
	err = internal.PolySetup()
	if err != nil {
		return internal.Wrap("poly setup", err)
	}
	internal.PixelResize()
	window.Events.Resize()
	internal.Running = true
	internal.RenderDelta = 0.0
	internal.UpdateLag = 0.0
	then := internal.GetSeconds()
	now := then
	gametime := 0.0
	internal.GameTime = gametime
	internal.Loop.Enter()
	for !internal.QuitRequested {
		internal.RenderDelta = now - then
		countFrames()
		if internal.RenderDelta > 4*internal.UpdateStep {
			internal.RenderDelta = 4 * internal.UpdateStep
		}
		internal.UpdateLag += internal.RenderDelta
		if internal.UpdateLag < internal.UpdateStep {
			internal.GameTime = now  
			internal.ProcessEvents(window.Events)
			internal.InputNewFrame()
			internal.Loop.React()
		}
		for internal.UpdateLag >= internal.UpdateStep {
			internal.UpdateLag -= internal.UpdateStep
			gametime += internal.UpdateStep
			internal.GameTime = gametime
			internal.ProcessEvents(window.Events)
			internal.InputNewFrame()
			internal.Loop.React()
			internal.Loop.Update()
		}
		err = internal.GLPrerender()
		if err != nil {
			return err
		}
		internal.GameTime = gametime + internal.UpdateLag  
		internal.Loop.Render()
		err = internal.PixelRender()
		if err != nil {
			return err
		}
		internal.SwapWindow()
		if next != nil {
			internal.Loop.Leave()
			internal.Loop = next
			next = nil
			internal.Loop.Enter()
		}
		then = now
		now = internal.GetSeconds()
	}
	internal.Loop.Leave()
	return stopErr
}
//////////////////////////////////////////////////////////////////////////////
Run initializes the framework, creates the ressources and loads all assets,
and finally starts the game loop. The loop will run until Stop is called.

Important: Run must be called from main.main, or at least from a function
that is known to run on the main OS thread.
package cozely
import (
	"github.com/cozely/cozely/internal"
	"github.com/cozely/cozely/window"
)
type GameLoop interface {
	Enter()
	Leave()
	React()
	Update()
	Render()
}
var next GameLoop