diff --git a/internal/graphicsdriver/opengl/driver.go b/internal/graphicsdriver/opengl/driver.go index a234266eb..581278168 100644 --- a/internal/graphicsdriver/opengl/driver.go +++ b/internal/graphicsdriver/opengl/driver.go @@ -32,6 +32,9 @@ func Get() *Driver { type Driver struct { state openGLState context context + + // drawCalled is true just after Draw is called. This holds true until ReplacePixels is called. + drawCalled bool } func (d *Driver) SetThread(thread *thread.Thread) { @@ -108,6 +111,7 @@ func (d *Driver) SetVertices(vertices []float32, indices []uint16) { } func (d *Driver) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, colorM *affine.ColorM, filter driver.Filter, address driver.Address) error { + d.drawCalled = true if err := d.useProgram(mode, colorM, filter, address); err != nil { return err } diff --git a/internal/graphicsdriver/opengl/image.go b/internal/graphicsdriver/opengl/image.go index 216f285c4..d4da73c1e 100644 --- a/internal/graphicsdriver/opengl/image.go +++ b/internal/graphicsdriver/opengl/image.go @@ -92,7 +92,10 @@ func (i *Image) ReplacePixels(p []byte, x, y, width, height int) { // glFlush is necessary on Android. // glTexSubImage2D didn't work without this hack at least on Nexus 5x and NuAns NEO [Reloaded] (#211). - i.driver.context.flush() + if i.driver.drawCalled { + i.driver.context.flush() + } + i.driver.drawCalled = false i.driver.context.texSubImage2D(i.textureNative, p, x, y, width, height) }