mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphics: Refactoring: remove ui goroutines
This commit is contained in:
parent
1062902872
commit
5cfefaf1a2
@ -49,13 +49,7 @@ func Init() {
|
|||||||
|
|
||||||
u := &userInterface{
|
u := &userInterface{
|
||||||
window: window,
|
window: window,
|
||||||
funcs: make(chan func()),
|
|
||||||
}
|
}
|
||||||
go func() {
|
|
||||||
for f := range u.funcs {
|
|
||||||
f()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
go func() {
|
go func() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
u.window.MakeContextCurrent()
|
u.window.MakeContextCurrent()
|
||||||
@ -67,14 +61,8 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExecOnUIThread(f func()) {
|
func ExecOnUIThread(f func()) {
|
||||||
// TODO: Rename this function: f is actually NOT executed on UI threads
|
|
||||||
ch := make(chan struct{})
|
|
||||||
currentUI.funcs <- func() {
|
|
||||||
defer close(ch)
|
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
<-ch
|
|
||||||
}
|
|
||||||
|
|
||||||
func Start(width, height, scale int, title string) (actualScale int, err error) {
|
func Start(width, height, scale int, title string) (actualScale int, err error) {
|
||||||
return currentUI.start(width, height, scale, title)
|
return currentUI.start(width, height, scale, title)
|
||||||
@ -112,7 +100,6 @@ type userInterface struct {
|
|||||||
height int
|
height int
|
||||||
scale int
|
scale int
|
||||||
actualScale int
|
actualScale int
|
||||||
funcs chan func()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user