mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Ported James Fry OPENGL2 patch to A3D
This commit is contained in:
@@ -3255,7 +3255,6 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
if (textTex == null) {
|
||||
textTex = new PFontTexture(parent, textFont, maxTextureSize, maxTextureSize);
|
||||
textFont.setCache(this, textTex);
|
||||
textTex.addAllGlyphsToTexture();
|
||||
}
|
||||
textTex.setFirstTexture();
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ public class PTexture implements PConstants {
|
||||
public int width, height;
|
||||
|
||||
protected PApplet parent;
|
||||
protected PGraphicsAndroid3D a3d;
|
||||
protected GL10 gl;
|
||||
protected PGraphicsAndroid3D a3d;
|
||||
|
||||
public int glID;
|
||||
public int glTarget;
|
||||
@@ -99,7 +98,6 @@ public class PTexture implements PConstants {
|
||||
this.height = height;
|
||||
|
||||
a3d = (PGraphicsAndroid3D)parent.g;
|
||||
gl = a3d.gl;
|
||||
|
||||
glID = 0;
|
||||
|
||||
@@ -128,7 +126,6 @@ public class PTexture implements PConstants {
|
||||
this.parent = parent;
|
||||
|
||||
a3d = (PGraphicsAndroid3D)parent.g;
|
||||
gl = a3d.gl;
|
||||
|
||||
glID = 0;
|
||||
|
||||
@@ -260,15 +257,15 @@ public class PTexture implements PConstants {
|
||||
createTexture(width, height);
|
||||
}
|
||||
|
||||
gl.glEnable(glTarget);
|
||||
gl.glBindTexture(glTarget, glID);
|
||||
getGl().glEnable(glTarget);
|
||||
getGl().glBindTexture(glTarget, glID);
|
||||
|
||||
if (usingMipmaps) {
|
||||
if (a3d.gl11 != null && PGraphicsAndroid3D.mipmapGeneration) {
|
||||
// Automatic mipmap generation.
|
||||
int[] rgbaPixels = new int[w * h];
|
||||
convertToRGBA(pixels, rgbaPixels, format, w, h);
|
||||
gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
|
||||
getGl().glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
|
||||
setTexels(x, y, w, h, rgbaPixels);
|
||||
} else {
|
||||
// Manual mipmap generation.
|
||||
@@ -323,8 +320,8 @@ public class PTexture implements PConstants {
|
||||
setTexels(x, y, w, h, rgbaPixels);
|
||||
}
|
||||
|
||||
gl.glBindTexture(glTarget, 0);
|
||||
gl.glDisable(glTarget);
|
||||
getGl().glBindTexture(glTarget, 0);
|
||||
getGl().glDisable(glTarget);
|
||||
}
|
||||
|
||||
|
||||
@@ -466,13 +463,13 @@ public class PTexture implements PConstants {
|
||||
// Bind/unbind
|
||||
|
||||
public void bind() {
|
||||
gl.glEnable(glTarget);
|
||||
gl.glBindTexture(glTarget, glID);
|
||||
getGl().glEnable(glTarget);
|
||||
getGl().glBindTexture(glTarget, glID);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
gl.glEnable(glTarget);
|
||||
gl.glBindTexture(glTarget, 0);
|
||||
getGl().glEnable(glTarget);
|
||||
getGl().glBindTexture(glTarget, 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -841,22 +838,22 @@ public class PTexture implements PConstants {
|
||||
|
||||
usingMipmaps = glMinFilter == GL10.GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
gl.glEnable(glTarget);
|
||||
getGl().glEnable(glTarget);
|
||||
glID = a3d.createGLResource(PGraphicsAndroid3D.GL_TEXTURE_OBJECT);
|
||||
gl.glBindTexture(glTarget, glID);
|
||||
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_MIN_FILTER, glMinFilter);
|
||||
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_MAG_FILTER, glMagFilter);
|
||||
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_S, glWrapS);
|
||||
gl.glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_T, glWrapT);
|
||||
getGl().glBindTexture(glTarget, glID);
|
||||
getGl().glTexParameterf(glTarget, GL10.GL_TEXTURE_MIN_FILTER, glMinFilter);
|
||||
getGl().glTexParameterf(glTarget, GL10.GL_TEXTURE_MAG_FILTER, glMagFilter);
|
||||
getGl().glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_S, glWrapS);
|
||||
getGl().glTexParameterf(glTarget, GL10.GL_TEXTURE_WRAP_T, glWrapT);
|
||||
|
||||
// This array is used to make sure that the texture doesn't contain any
|
||||
// garbage.
|
||||
int[] initArray = new int[glWidth * glHeight];
|
||||
java.util.Arrays.fill(initArray, 0, glWidth * glHeight, 0x00000000);
|
||||
gl.glTexImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, GL10.GL_RGBA,
|
||||
GL10.GL_UNSIGNED_BYTE, IntBuffer.wrap(initArray));
|
||||
gl.glBindTexture(glTarget, 0);
|
||||
gl.glDisable(glTarget);
|
||||
getGl().glTexImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, GL10.GL_RGBA,
|
||||
GL10.GL_UNSIGNED_BYTE, IntBuffer.wrap(initArray));
|
||||
getGl().glBindTexture(glTarget, 0);
|
||||
getGl().glDisable(glTarget);
|
||||
|
||||
flippedX = false;
|
||||
flippedY = false;
|
||||
@@ -915,7 +912,7 @@ public class PTexture implements PConstants {
|
||||
}
|
||||
|
||||
protected void setTexels(int level, int x, int y, int w, int h, int[] pix) {
|
||||
gl.glTexSubImage2D(glTarget, 0, x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, IntBuffer.wrap(pix));
|
||||
getGl().glTexSubImage2D(glTarget, 0, x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, IntBuffer.wrap(pix));
|
||||
}
|
||||
|
||||
protected void copyObject(PTexture src) {
|
||||
@@ -928,7 +925,6 @@ public class PTexture implements PConstants {
|
||||
|
||||
parent = src.parent;
|
||||
a3d = src.a3d;
|
||||
gl = src.gl;
|
||||
|
||||
glID = src.glID;
|
||||
glTarget = src.glTarget;
|
||||
@@ -1043,7 +1039,16 @@ public class PTexture implements PConstants {
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Utilities
|
||||
|
||||
|
||||
protected GL10 getGl() {
|
||||
return a3d.gl;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Parameters object
|
||||
|
||||
Reference in New Issue
Block a user