graphics: Bug fix: glTexSubImage2D on Android now works (#211)

This commit is contained in:
Hajime Hoshi 2016-07-10 05:59:21 +09:00
parent 1b152ae771
commit 0c611d875b
2 changed files with 4 additions and 2 deletions

View File

@ -182,8 +182,6 @@ func (i *Image) Dispose() error {
// This function may be slow (as for implementation, this calls glTexSubImage2D).
//
// This function is concurrent-safe.
//
// BUG(hajimehoshi) ReplacePixels might not work on Android (#211).
func (i *Image) ReplacePixels(p []uint8) error {
return i.impl.ReplacePixels(p)
}

View File

@ -157,6 +157,10 @@ func (c *replacePixelsCommand) Exec(context *opengl.Context) error {
if err := context.FillFramebuffer(0, 0, 0.5, 1); err != nil {
return err
}
// This is necessary on Android. We can't call glClear just before glTexSubImage2D without
// glFlush. glTexSubImage2D didn't work without this hack at least on Nexus 5x (#211).
// TODO: Can we have a better way like optimizing commands?
context.Flush()
context.BindTexture(c.dst.texture.native)
context.TexSubImage2D(c.pixels, c.dst.width, c.dst.height)
return nil