From 205b73bf891dcec9fe2c8bbceed141c2ab98f351 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Wed, 13 Apr 2016 16:49:24 -0400 Subject: [PATCH] flushes after drawing the source texture, fixes #4404 --- core/src/processing/opengl/FontTexture.java | 8 +------- core/src/processing/opengl/Texture.java | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/core/src/processing/opengl/FontTexture.java b/core/src/processing/opengl/FontTexture.java index c4c207b73..af28ad9f3 100644 --- a/core/src/processing/opengl/FontTexture.java +++ b/core/src/processing/opengl/FontTexture.java @@ -149,15 +149,9 @@ class FontTexture implements PConstants { } else if (resize) { // Replacing old smaller texture with larger one. // But first we must copy the contents of the older - // texture into the new one. Setting blend mode to - // REPLACE to preserve color of transparent pixels. + // texture into the new one. Texture tex0 = textures[lastTex]; - - tex.pg.pushStyle(); - tex.pg.blendMode(REPLACE); tex.put(tex0); - tex.pg.popStyle(); - textures[lastTex] = tex; pg.setCache(images[lastTex], tex); diff --git a/core/src/processing/opengl/Texture.java b/core/src/processing/opengl/Texture.java index 5d8a2a8d3..c2f75f3f2 100644 --- a/core/src/processing/opengl/Texture.java +++ b/core/src/processing/opengl/Texture.java @@ -1224,10 +1224,10 @@ public class Texture implements PConstants { // FBO copy: pg.pushFramebuffer(); pg.setFramebuffer(tempFbo); - // Clear the color buffer to make sure that the alpha channel is set to - // full transparency - pgl.clearColor(0, 0, 0, 0); - pgl.clear(PGL.COLOR_BUFFER_BIT); + // Replaces anything that this texture might contain in the area being + // replaced by the new one. + pg.pushStyle(); + pg.blendMode(REPLACE); if (scale) { // Rendering tex into "this", and scaling the source rectangle // to cover the entire destination region. @@ -1243,8 +1243,10 @@ public class Texture implements PConstants { 0, 0, tempFbo.width, tempFbo.height, 1, x, y, x + w, y + h, x, y, x + w, y + h); } + pgl.flush(); // Needed to make sure that the change in this texture is + // available immediately. + pg.popStyle(); pg.popFramebuffer(); - updateTexels(x, y, w, h); } @@ -1264,6 +1266,10 @@ public class Texture implements PConstants { // FBO copy: pg.pushFramebuffer(); pg.setFramebuffer(tempFbo); + // Replaces anything that this texture might contain in the area being + // replaced by the new one. + pg.pushStyle(); + pg.blendMode(REPLACE); if (scale) { // Rendering tex into "this", and scaling the source rectangle // to cover the entire destination region. @@ -1279,6 +1285,9 @@ public class Texture implements PConstants { 0, 0, tempFbo.width, tempFbo.height, x, y, w, h, x, y, w, h); } + pgl.flush(); // Needed to make sure that the change in this texture is + // available immediately. + pg.popStyle(); pg.popFramebuffer(); updateTexels(x, y, w, h); }