android: Bug fix: Black flicking (#226)

This commit is contained in:
Hajime Hoshi 2016-06-07 02:24:36 +09:00
parent 9757319848
commit 83a96dc532
6 changed files with 25 additions and 4 deletions

View File

@ -75,7 +75,6 @@ func (c *graphicsContext) Update() error {
if IsRunningSlowly() {
return nil
}
// TODO: In WebGL, we don't need to clear the image here.
if err := c.defaultRenderTarget.Clear(); err != nil {
return err
}

View File

@ -62,6 +62,8 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
return err
}
}
// Call glFlush to prevent black flicking (especially on Android (#226)).
context.Flush()
q.commands = []command{}
return nil
}
@ -103,7 +105,6 @@ func (c *drawImageCommand) Exec(context *opengl.Context) error {
if n == 0 {
return nil
}
p := programContext{
state: &theOpenGLState,
program: theOpenGLState.programTexture,

View File

@ -454,3 +454,10 @@ func (c *Context) DrawElements(mode Mode, len int, offsetInBytes int) {
return nil
})
}
func (c *Context) Flush() {
c.RunOnContextThread(func() error {
gl.Flush()
return nil
})
}

View File

@ -370,3 +370,8 @@ func (c *Context) DrawElements(mode Mode, len int, offsetInBytes int) {
gl := c.gl
gl.DrawElements(int(mode), len, gl.UNSIGNED_SHORT, offsetInBytes)
}
func (c *Context) Flush() {
gl := c.gl
gl.Flush()
}

View File

@ -373,3 +373,8 @@ func (c *Context) DrawElements(mode Mode, len int, offsetInBytes int) {
gl := c.gl
gl.DrawElements(mgl.Enum(mode), len, mgl.UNSIGNED_SHORT, offsetInBytes)
}
func (c *Context) Flush() {
gl := c.gl
gl.Flush()
}

View File

@ -44,8 +44,12 @@ loop:
return err
case <-worker.WorkAvailable():
worker.DoWork()
case <-chRenderEnd:
break loop
default:
select {
case <-chRenderEnd:
break loop
default:
}
}
}
return nil