diff --git a/exp/audio/audio.go b/exp/audio/audio.go index 372db1d4e..3d3e903db 100644 --- a/exp/audio/audio.go +++ b/exp/audio/audio.go @@ -15,7 +15,7 @@ package audio import ( - "github.com/hajimehoshi/ebiten/exp/audio/internal" + "github.com/hajimehoshi/ebiten/exp/audio/inner" ) // SampleRate returns the sampling frequency (e.g. 44100). diff --git a/exp/audio/internal/audio.go b/exp/audio/inner/audio.go similarity index 100% rename from exp/audio/internal/audio.go rename to exp/audio/inner/audio.go diff --git a/exp/audio/internal/audio_js.go b/exp/audio/inner/audio_js.go similarity index 100% rename from exp/audio/internal/audio_js.go rename to exp/audio/inner/audio_js.go diff --git a/exp/audio/internal/audio_openal.go b/exp/audio/inner/audio_openal.go similarity index 100% rename from exp/audio/internal/audio_openal.go rename to exp/audio/inner/audio_openal.go diff --git a/exp/audio/internal/audio_windows.go b/exp/audio/inner/audio_windows.go similarity index 100% rename from exp/audio/internal/audio_windows.go rename to exp/audio/inner/audio_windows.go diff --git a/gamecontext.go b/gamecontext.go index f41ec1136..902545647 100644 --- a/gamecontext.go +++ b/gamecontext.go @@ -15,9 +15,9 @@ package ebiten import ( - audio "github.com/hajimehoshi/ebiten/exp/audio/internal" + audio "github.com/hajimehoshi/ebiten/exp/audio/inner" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "github.com/hajimehoshi/ebiten/internal/ui" "image" ) diff --git a/graphics.go b/graphics.go index 749eba307..731483456 100644 --- a/graphics.go +++ b/graphics.go @@ -15,7 +15,7 @@ package ebiten import ( - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" ) // Filter represents the type of filter to be used when an image is maginified or minified. diff --git a/graphicscontext.go b/graphicscontext.go index 615824cd9..abe55d86f 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -16,7 +16,7 @@ package ebiten import ( "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "github.com/hajimehoshi/ebiten/internal/ui" ) diff --git a/image.go b/image.go index eaa9c1d00..8985f9ce9 100644 --- a/image.go +++ b/image.go @@ -18,7 +18,7 @@ import ( "errors" "fmt" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "image" "image/color" ) diff --git a/internal/graphics/draw.go b/internal/graphics/draw.go index ab60363a5..db9a16949 100644 --- a/internal/graphics/draw.go +++ b/internal/graphics/draw.go @@ -17,7 +17,7 @@ package graphics import ( "errors" "fmt" - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" ) func glMatrix(m *[4][4]float64) []float32 { diff --git a/internal/graphics/framebuffer.go b/internal/graphics/framebuffer.go index f1de5fb3a..7b3143575 100644 --- a/internal/graphics/framebuffer.go +++ b/internal/graphics/framebuffer.go @@ -15,7 +15,7 @@ package graphics import ( - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "image/color" "math" ) diff --git a/internal/graphics/internal/opengl/context.go b/internal/graphics/opengl/context.go similarity index 98% rename from internal/graphics/internal/opengl/context.go rename to internal/graphics/opengl/context.go index d13e484b6..e95c6e1a1 100644 --- a/internal/graphics/internal/opengl/context.go +++ b/internal/graphics/opengl/context.go @@ -73,6 +73,12 @@ func (c *Context) init() { gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) } +func (c *Context) Check() { + if e := gl.GetError(); e != gl.NO_ERROR { + panic(fmt.Sprintf("check failed: %d", e)) + } +} + func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (Texture, error) { var t uint32 gl.GenTextures(1, &t) diff --git a/internal/graphics/internal/opengl/context_js.go b/internal/graphics/opengl/context_js.go similarity index 100% rename from internal/graphics/internal/opengl/context_js.go rename to internal/graphics/opengl/context_js.go diff --git a/internal/graphics/internal/opengl/locationcache.go b/internal/graphics/opengl/locationcache.go similarity index 100% rename from internal/graphics/internal/opengl/locationcache.go rename to internal/graphics/opengl/locationcache.go diff --git a/internal/graphics/internal/opengl/types.go b/internal/graphics/opengl/types.go similarity index 100% rename from internal/graphics/internal/opengl/types.go rename to internal/graphics/opengl/types.go diff --git a/internal/graphics/program.go b/internal/graphics/program.go index 402009354..39c24493f 100644 --- a/internal/graphics/program.go +++ b/internal/graphics/program.go @@ -15,7 +15,7 @@ package graphics import ( - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "math" ) diff --git a/internal/graphics/shader.go b/internal/graphics/shader.go index 4c69ef2fb..a1002e7eb 100644 --- a/internal/graphics/shader.go +++ b/internal/graphics/shader.go @@ -15,7 +15,7 @@ package graphics import ( - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "strings" ) diff --git a/internal/graphics/texture.go b/internal/graphics/texture.go index 98363cf1f..d6569c791 100644 --- a/internal/graphics/texture.go +++ b/internal/graphics/texture.go @@ -16,7 +16,7 @@ package graphics import ( "errors" - "github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" + "github.com/hajimehoshi/ebiten/internal/graphics/opengl" "image" "image/draw" ) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 877015284..b31863b3b 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -64,10 +64,16 @@ func Init() { func ExecOnUIThread(f func()) { ch := make(chan struct{}) - currentUI.funcs <- func() { + /*currentUI.funcs <- func() { defer close(ch) f() - } + }*/ + go func() { + defer close(ch) + runtime.LockOSThread() + currentUI.window.MakeContextCurrent() + f() + }() <-ch } diff --git a/run.go b/run.go index 774e4a539..cdf3e2928 100644 --- a/run.go +++ b/run.go @@ -15,7 +15,7 @@ package ebiten import ( - audio "github.com/hajimehoshi/ebiten/exp/audio/internal" + audio "github.com/hajimehoshi/ebiten/exp/audio/inner" "github.com/hajimehoshi/ebiten/internal/ui" "time" ) @@ -54,6 +54,10 @@ func Run(f func(*Image) error, width, height, scale int, title string) error { } defer ui.Terminate() + ui.ExecOnUIThread(func() { + glContext.Check() + }) + graphicsContext, err := newGraphicsContext(width, height, actualScale) if err != nil { return err