From 6207760c1c58a603f56c8178508db949565d297b Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 14 Jun 2010 03:31:07 +0000 Subject: [PATCH] Some minor code changes in A3D --- android/core/src/processing/core/PFont.java | 9 ++++---- .../processing/core/PGraphicsAndroid3D.java | 21 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/android/core/src/processing/core/PFont.java b/android/core/src/processing/core/PFont.java index d434cc044..d8269cdb1 100644 --- a/android/core/src/processing/core/PFont.java +++ b/android/core/src/processing/core/PFont.java @@ -672,7 +672,7 @@ public class PFont implements PConstants { // OPENGL stuff - public void initialize(GL10 gl, int w, int h) { + public void initTexture(GL10 gl, int w, int h) { gl10 = gl; texWidth = w; texHeight = h; @@ -686,11 +686,11 @@ public class PFont implements PConstants { public int addTexture(GL10 gl) { int[] textures = new int[1]; - gl.glEnable(GL10.GL_TEXTURE_2D); + + // We assume GL10.GL_TEXTURE_2D is enabled at this point. gl.glGenTextures(1, textures, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); - // Use Nearest for performance. gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST); @@ -932,7 +932,8 @@ public class PFont implements PConstants { if (lastTexID == -1) { lastTexID = texIDList[0]; } - gl.glEnable(GL10.GL_TEXTURE_2D); + + // We assume GL10.GL_TEXTURE_2D is enabled at this point. gl.glBindTexture(GL10.GL_TEXTURE_2D, lastTexID); currentTexID = lastTexID; diff --git a/android/core/src/processing/core/PGraphicsAndroid3D.java b/android/core/src/processing/core/PGraphicsAndroid3D.java index b95478624..033162381 100644 --- a/android/core/src/processing/core/PGraphicsAndroid3D.java +++ b/android/core/src/processing/core/PGraphicsAndroid3D.java @@ -2133,18 +2133,9 @@ public class PGraphicsAndroid3D extends PGraphics { */ protected void textLineImpl(char buffer[], int start, int stop, float x, float y) { - - if (textFont.texIDList == null) { - textFont.initialize(gl, maxTextureSize, maxTextureSize); - // Add all the current glyphs to the texture. - textFont.addAllGlyphsToTexture(gl); - } - // Init opengl state for text rendering... gl.glEnable(GL10.GL_TEXTURE_2D); - textFont.currentTexID = textFont.texIDList[0]; - gl.glBindTexture(GL10.GL_TEXTURE_2D, textFont.currentTexID); - + gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); @@ -2153,6 +2144,15 @@ public class PGraphicsAndroid3D extends PGraphics { gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); + + if (textFont.texIDList == null) { + textFont.initTexture(gl, maxTextureSize, maxTextureSize); + // Add all the current glyphs to the texture. + textFont.addAllGlyphsToTexture(gl); + } + + textFont.currentTexID = textFont.texIDList[0]; + gl.glBindTexture(GL10.GL_TEXTURE_2D, textFont.currentTexID); // Setting the current fill color as the font color. gl.glColor4f(colorFloats[0], colorFloats[1], colorFloats[2], colorFloats[3]); @@ -2164,7 +2164,6 @@ public class PGraphicsAndroid3D extends PGraphics { gl.glPopMatrix(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPopMatrix(); - gl.glDisable(GL10.GL_TEXTURE_2D); }