Skip to content

Commit 7a0e2f2

Browse files
committed
flush font texture fix
1 parent 11990e0 commit 7a0e2f2

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

core/src/processing/opengl/FontTexture.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,9 @@ public boolean addTexture(PGraphicsOpenGL pg) {
149149
} else if (resize) {
150150
// Replacing old smaller texture with larger one.
151151
// But first we must copy the contents of the older
152-
// texture into the new one. Setting blend mode to
153-
// REPLACE to preserve color of transparent pixels.
152+
// texture into the new one.
154153
Texture tex0 = textures[lastTex];
155-
156-
tex.pg.pushStyle();
157-
tex.pg.blendMode(REPLACE);
158154
tex.put(tex0);
159-
tex.pg.popStyle();
160-
161155
textures[lastTex] = tex;
162156

163157
pg.setCache(images[lastTex], tex);

core/src/processing/opengl/Texture.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,10 +1224,10 @@ protected void copyTexture(Texture tex, int x, int y, int w, int h,
12241224
// FBO copy:
12251225
pg.pushFramebuffer();
12261226
pg.setFramebuffer(tempFbo);
1227-
// Clear the color buffer to make sure that the alpha channel is set to
1228-
// full transparency
1229-
pgl.clearColor(0, 0, 0, 0);
1230-
pgl.clear(PGL.COLOR_BUFFER_BIT);
1227+
// Replaces anything that this texture might contain in the area being
1228+
// replaced by the new one.
1229+
pg.pushStyle();
1230+
pg.blendMode(REPLACE);
12311231
if (scale) {
12321232
// Rendering tex into "this", and scaling the source rectangle
12331233
// to cover the entire destination region.
@@ -1243,8 +1243,10 @@ protected void copyTexture(Texture tex, int x, int y, int w, int h,
12431243
0, 0, tempFbo.width, tempFbo.height, 1,
12441244
x, y, x + w, y + h, x, y, x + w, y + h);
12451245
}
1246+
pgl.flush(); // Needed to make sure that the change in this texture is
1247+
// available immediately.
1248+
pg.popStyle();
12461249
pg.popFramebuffer();
1247-
12481250
updateTexels(x, y, w, h);
12491251
}
12501252

@@ -1264,6 +1266,10 @@ protected void copyTexture(int texTarget, int texName,
12641266
// FBO copy:
12651267
pg.pushFramebuffer();
12661268
pg.setFramebuffer(tempFbo);
1269+
// Replaces anything that this texture might contain in the area being
1270+
// replaced by the new one.
1271+
pg.pushStyle();
1272+
pg.blendMode(REPLACE);
12671273
if (scale) {
12681274
// Rendering tex into "this", and scaling the source rectangle
12691275
// to cover the entire destination region.
@@ -1279,6 +1285,9 @@ protected void copyTexture(int texTarget, int texName,
12791285
0, 0, tempFbo.width, tempFbo.height,
12801286
x, y, w, h, x, y, w, h);
12811287
}
1288+
pgl.flush(); // Needed to make sure that the change in this texture is
1289+
// available immediately.
1290+
pg.popStyle();
12821291
pg.popFramebuffer();
12831292
updateTexels(x, y, w, h);
12841293
}

0 commit comments

Comments
 (0)