From bdbc77a6cbffd552cd943a9c9b52fb95534004f3 Mon Sep 17 00:00:00 2001 From: Benjamin Maus Date: Fri, 17 May 2013 23:38:25 +0200 Subject: [PATCH] Fixed: When using the PGraphicsOpenGL renderer Processing would allocate a texture with the maximum allowed width (e.g. 8192x512 pixels for a 10px font) for each font. This lead to severe GPU memory problems, especially when using multiple fonts. Merge doubled code. --- core/src/processing/opengl/PGraphicsOpenGL.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 8f2fb3e8a..28936fe5c 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -3276,18 +3276,14 @@ public class PGraphicsOpenGL extends PGraphics { protected void textLineImpl(char buffer[], int start, int stop, float x, float y) { textTex = pgPrimary.getFontTexture(textFont); - if (textTex == null) { - textTex = new FontTexture(pgPrimary, textFont, maxTextureSize, - maxTextureSize, is3D()); - pgPrimary.setFontTexture(textFont, textTex); - } else { - if (textTex.contextIsOutdated()) { - textTex = new FontTexture(pgPrimary, textFont, + + if (textTex == null || textTex.contextIsOutdated()) { + textTex = new FontTexture(pgPrimary, textFont, PApplet.min(PGL.MAX_FONT_TEX_SIZE, maxTextureSize), PApplet.min(PGL.MAX_FONT_TEX_SIZE, maxTextureSize), is3D()); - pgPrimary.setFontTexture(textFont, textTex); - } + pgPrimary.setFontTexture(textFont, textTex); } + textTex.begin(); // Saving style parameters modified by text rendering.