#132 Temporal hack to run with Go1.5

This commit is contained in:
Hajime Hoshi 2015-07-22 23:27:50 +09:00
parent 0bc321d3ef
commit 633ee4096e
20 changed files with 30 additions and 14 deletions

View File

@ -15,7 +15,7 @@
package audio package audio
import ( import (
"github.com/hajimehoshi/ebiten/exp/audio/internal" "github.com/hajimehoshi/ebiten/exp/audio/inner"
) )
// SampleRate returns the sampling frequency (e.g. 44100). // SampleRate returns the sampling frequency (e.g. 44100).

View File

@ -15,9 +15,9 @@
package ebiten package ebiten
import ( 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"
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
"github.com/hajimehoshi/ebiten/internal/ui" "github.com/hajimehoshi/ebiten/internal/ui"
"image" "image"
) )

View File

@ -15,7 +15,7 @@
package ebiten package ebiten
import ( 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. // Filter represents the type of filter to be used when an image is maginified or minified.

View File

@ -16,7 +16,7 @@ package ebiten
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphics" "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" "github.com/hajimehoshi/ebiten/internal/ui"
) )

View File

@ -18,7 +18,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
"image" "image"
"image/color" "image/color"
) )

View File

@ -17,7 +17,7 @@ package graphics
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
) )
func glMatrix(m *[4][4]float64) []float32 { func glMatrix(m *[4][4]float64) []float32 {

View File

@ -15,7 +15,7 @@
package graphics package graphics
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
"image/color" "image/color"
"math" "math"
) )

View File

@ -73,6 +73,12 @@ func (c *Context) init() {
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) 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) { func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) (Texture, error) {
var t uint32 var t uint32
gl.GenTextures(1, &t) gl.GenTextures(1, &t)

View File

@ -15,7 +15,7 @@
package graphics package graphics
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
"math" "math"
) )

View File

@ -15,7 +15,7 @@
package graphics package graphics
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
"strings" "strings"
) )

View File

@ -16,7 +16,7 @@ package graphics
import ( import (
"errors" "errors"
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl" "github.com/hajimehoshi/ebiten/internal/graphics/opengl"
"image" "image"
"image/draw" "image/draw"
) )

View File

@ -64,10 +64,16 @@ func Init() {
func ExecOnUIThread(f func()) { func ExecOnUIThread(f func()) {
ch := make(chan struct{}) ch := make(chan struct{})
currentUI.funcs <- func() { /*currentUI.funcs <- func() {
defer close(ch) defer close(ch)
f() f()
} }*/
go func() {
defer close(ch)
runtime.LockOSThread()
currentUI.window.MakeContextCurrent()
f()
}()
<-ch <-ch
} }

6
run.go
View File

@ -15,7 +15,7 @@
package ebiten package ebiten
import ( import (
audio "github.com/hajimehoshi/ebiten/exp/audio/internal" audio "github.com/hajimehoshi/ebiten/exp/audio/inner"
"github.com/hajimehoshi/ebiten/internal/ui" "github.com/hajimehoshi/ebiten/internal/ui"
"time" "time"
) )
@ -54,6 +54,10 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
} }
defer ui.Terminate() defer ui.Terminate()
ui.ExecOnUIThread(func() {
glContext.Check()
})
graphicsContext, err := newGraphicsContext(width, height, actualScale) graphicsContext, err := newGraphicsContext(width, height, actualScale)
if err != nil { if err != nil {
return err return err