mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Some minor code changes in A3D
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user