mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
back porting to A3D
This commit is contained in:
@@ -42,11 +42,12 @@ public class PFramebuffer implements PConstants {
|
||||
protected PGraphicsAndroid3D a3d;
|
||||
protected GL10 gl;
|
||||
protected GL11ExtensionPack gl11xp;
|
||||
protected int glFboID;
|
||||
protected int glDepthBufferID;
|
||||
protected int glStencilBufferID;
|
||||
protected int width;
|
||||
protected int height;
|
||||
|
||||
public int glFboID;
|
||||
public int glDepthBufferID;
|
||||
public int glStencilBufferID;
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
protected int numColorBuffers;
|
||||
protected int[] colorBufferAttchPoints;
|
||||
@@ -133,15 +134,15 @@ public class PFramebuffer implements PConstants {
|
||||
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
colorBufferAttchPoints[i] = GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES + i;
|
||||
glColorBufferTargets[i] = textures[i].getGLTarget();
|
||||
glColorBufferIDs[i] = textures[i].getGLID();
|
||||
glColorBufferTargets[i] = textures[i].glTarget;
|
||||
glColorBufferIDs[i] = textures[i].glID;
|
||||
gl11xp.glFramebufferTexture2DOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, colorBufferAttchPoints[i],
|
||||
glColorBufferTargets[i], glColorBufferIDs[i], 0);
|
||||
}
|
||||
|
||||
if (validFbo() && textures != null && 0 < textures.length) {
|
||||
width = textures[0].getGLWidth();
|
||||
height = textures[0].getGLHeight();
|
||||
width = textures[0].glWidth;
|
||||
height = textures[0].glHeight;
|
||||
}
|
||||
|
||||
a3d.popFramebuffer();
|
||||
@@ -150,8 +151,8 @@ public class PFramebuffer implements PConstants {
|
||||
glColorBufferTargets = new int[numColorBuffers];
|
||||
glColorBufferIDs = new int[numColorBuffers];
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
glColorBufferTargets[i] = textures[i].getGLTarget();
|
||||
glColorBufferIDs[i] = textures[i].getGLID();
|
||||
glColorBufferTargets[i] = textures[i].glTarget;
|
||||
glColorBufferIDs[i] = textures[i].glID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +271,7 @@ public class PFramebuffer implements PConstants {
|
||||
public void backupScreen() {
|
||||
if (pixelBuffer == null) allocatePixelBuffer();
|
||||
gl.glReadPixels(0, 0, width, height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
copyToTexture(pixelBuffer, backupTexture.getGLID(), backupTexture.getGLTarget());
|
||||
copyToTexture(pixelBuffer, backupTexture.glID, backupTexture.glTarget);
|
||||
}
|
||||
|
||||
// Draws the contents of the backup texture to the screen.
|
||||
|
||||
@@ -71,20 +71,22 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
// GL parameters
|
||||
|
||||
/** Extensions used by Processing */
|
||||
static protected boolean npotTexSupported;
|
||||
static protected boolean mipmapGeneration;
|
||||
static protected boolean matrixGetSupported;
|
||||
static protected boolean vboSupported;
|
||||
static protected boolean fboSupported;
|
||||
static protected boolean blendEqSupported;
|
||||
static protected boolean texenvCrossbarSupported;
|
||||
static protected boolean glParamsRead = false;
|
||||
|
||||
/** Extensions used by Processing */
|
||||
static protected int maxTextureSize;
|
||||
static protected float maxPointSize;
|
||||
static protected float maxLineWidth;
|
||||
static protected int maxTextureUnits;
|
||||
static public boolean npotTexSupported;
|
||||
static public boolean mipmapGeneration;
|
||||
static public boolean matrixGetSupported;
|
||||
static public boolean vboSupported;
|
||||
static public boolean fboSupported;
|
||||
static public boolean blendEqSupported;
|
||||
static public boolean texenvCrossbarSupported;
|
||||
|
||||
/** Extensions used by Processing */
|
||||
static public int maxTextureSize;
|
||||
static public float maxPointSize;
|
||||
static public float maxLineWidth;
|
||||
static public int maxTextureUnits;
|
||||
|
||||
/** OpenGL information strings */
|
||||
static public String OPENGL_VENDOR;
|
||||
@@ -2264,9 +2266,9 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
break;
|
||||
}
|
||||
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL10.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
renderTextures[tcount] = tex;
|
||||
tcount++;
|
||||
} else {
|
||||
@@ -2280,9 +2282,9 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (images[0] != null) {
|
||||
PTexture tex = getTexture(images[0]);
|
||||
if (tex != null) {
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL10.GL_TEXTURE0);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
renderTextures[0] = tex;
|
||||
tcount = 1;
|
||||
}
|
||||
@@ -2643,7 +2645,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
for (int t = 0; t < tcount; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glActiveTexture(GL10.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
}
|
||||
// Disable the texture targets at the end in a separate loop, otherwise the
|
||||
// textures are not properly unbound. Example: we have multitexturing, with
|
||||
@@ -2652,7 +2654,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
// glBindTexture in the second iteration.
|
||||
for (int t = 0; t < tcount; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
for (int t = 0; t < tcount; t++) {
|
||||
gl.glClientActiveTexture(GL10.GL_TEXTURE0 + t);
|
||||
@@ -5657,7 +5659,10 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
// LOAD/UPDATE (SCREEN) TEXTURE
|
||||
|
||||
public void loadTexture() {
|
||||
if (primarySurface) {
|
||||
if (primarySurface && !fboSupported) {
|
||||
// We need to explicitly load the texture and
|
||||
// copy the pixels to it only if this renderer is
|
||||
// the primary surface and there is no FBO.
|
||||
loadTextureImpl(POINT);
|
||||
loadPixels();
|
||||
pixelsToTexture();
|
||||
@@ -5981,22 +5986,22 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
if (texBlendMode == REPLACE) {
|
||||
// Texture 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Simply sample the texture:
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE1);
|
||||
gl11.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl11.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
// Sample the texture, replacing the previous one.
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
|
||||
} else if (texBlendMode == BLEND) {
|
||||
// Texture 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE1);
|
||||
gl11.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl11.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Interpolate RGB with RGB...
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_INTERPOLATE);
|
||||
@@ -6019,12 +6024,12 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (texBlendMode == MULTIPLY) {
|
||||
// Texture 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Simply sample the texture.
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE1);
|
||||
gl11.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl11.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
// Combine this texture with the previous one.
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Modulate (multiply) RGB with RGB:
|
||||
@@ -6041,11 +6046,11 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_OPERAND1_ALPHA, GL11.GL_SRC_ALPHA);
|
||||
} else if (texBlendMode == ADD) {
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
|
||||
// Add RGB with RGB:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE1);
|
||||
gl11.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl11.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_ADD);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_SRC0_RGB, GL11.GL_PREVIOUS);
|
||||
@@ -6061,11 +6066,11 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (texBlendMode == SUBTRACT) {
|
||||
// Texture 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
|
||||
// Texture 1:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE1);
|
||||
gl11.glBindTexture(textures[1].getGLTarget(), textures[1].getGLID());
|
||||
gl11.glBindTexture(textures[1].glTarget, textures[1].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Subtract RGB with RGB:
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_SUBTRACT);
|
||||
@@ -6090,7 +6095,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
if (texBlendMode == REPLACE) {
|
||||
// Sampler 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Replace using texture 1:
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Replace RGB:
|
||||
@@ -6106,7 +6111,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (texBlendMode == BLEND) {
|
||||
// Sampler 0: interpolation between textures 0 and 1 using alpha of 1.
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Interpolate RGB with RGB...
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_INTERPOLATE);
|
||||
@@ -6131,7 +6136,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (texBlendMode == MULTIPLY) {
|
||||
// Sampler 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Modulate (multiply) texture 0 with texture 1.
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Modulate RGB with RGB:
|
||||
@@ -6151,7 +6156,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (texBlendMode == ADD) {
|
||||
// Sampler 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Add texture 0 to texture 1:
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_ADD);
|
||||
@@ -6170,7 +6175,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
} else if (texBlendMode == SUBTRACT) {
|
||||
// Sampler 0:
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0);
|
||||
gl11.glBindTexture(textures[0].getGLTarget(), textures[0].getGLID());
|
||||
gl11.glBindTexture(textures[0].glTarget, textures[0].glID);
|
||||
// Substract texture 1 from texture 0:
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
// Subtract RGB with RGB:
|
||||
@@ -6198,7 +6203,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
protected void modulateWithPrimaryColor(int unit, PTexture tex) {
|
||||
gl11.glActiveTexture(GL11.GL_TEXTURE0 + unit);
|
||||
gl11.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl11.glBindTexture(tex.glTarget, tex.glID);
|
||||
// Interpolate RGB of previous color (result of blending in sampler 0) with RGB
|
||||
// of primary color (tinted and lit from pixel)...
|
||||
gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
|
||||
@@ -6289,7 +6294,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
offscreenIndex = 0;
|
||||
|
||||
offscreenFramebuffer = new PFramebuffer(parent, offscreenTextures[0].getGLWidth(), offscreenTextures[0].getGLHeight(), false);
|
||||
offscreenFramebuffer = new PFramebuffer(parent, offscreenTextures[0].glWidth, offscreenTextures[0].glHeight, false);
|
||||
|
||||
offscreenFramebuffer.addDepthBuffer(offscreenDepthBits);
|
||||
if (0 < offscreenStencilBits) {
|
||||
@@ -6322,12 +6327,25 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
// TEXTURE UTILS
|
||||
|
||||
/**
|
||||
* This utility method returns the texture associated to the renderer's.
|
||||
* drawing surface, making sure is updated to reflect the current contents
|
||||
* off the screen (or offscreen drawing surface). If called from the
|
||||
* main renderer, and trying to use the returned texture for further
|
||||
* drawing operations, unexpected outcomes might occur since the
|
||||
* texture is currently bound as the color buffer.
|
||||
*/
|
||||
public PTexture getTexture() {
|
||||
loadTexture();
|
||||
return texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* This utility method returns the texture associated to the image.
|
||||
* creating and/or updating it if needed.
|
||||
* @param img the image to have a texture metadata associated to it
|
||||
*/
|
||||
protected PTexture getTexture(PImage img) {
|
||||
public PTexture getTexture(PImage img) {
|
||||
PTexture tex = (PTexture)img.getCache(a3d);
|
||||
if (tex == null) {
|
||||
tex = addTexture(img);
|
||||
@@ -6376,8 +6394,8 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
/** Utility function to render texture. */
|
||||
protected void drawTexture(PTexture tex, int[] crop, int x, int y, int w, int h) {
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
gl.glDepthMask(false);
|
||||
gl.glDisable(GL10.GL_BLEND);
|
||||
|
||||
@@ -6399,8 +6417,8 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
// with the current fragment color.
|
||||
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
|
||||
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
gl.glDisable(tex.glTarget);
|
||||
|
||||
if (hints[DISABLE_DEPTH_MASK]) {
|
||||
gl.glDepthMask(false);
|
||||
@@ -6424,11 +6442,11 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
// Utility function to copy buffer to texture
|
||||
protected void copyToTexture(PTexture tex, IntBuffer buffer, int x, int y, int w, int h) {
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glTexSubImage2D(tex.getGLTarget(), 0, x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, buffer);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
gl.glTexSubImage2D(tex.glTarget, 0, x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, buffer);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
@@ -6490,7 +6508,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
}
|
||||
} else {
|
||||
if (gl11 == null || gl11x == null) {
|
||||
throw new RuntimeException("A3D: no clear mode with no FBOs requires OpenGL ES 1.1");
|
||||
throw new RuntimeException("A3D: no clear mode without FBOs requires OpenGL ES 1.1");
|
||||
}
|
||||
if (texture == null) {
|
||||
loadTextureImpl(POINT);
|
||||
@@ -6914,9 +6932,9 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
if (0 < texCount) {
|
||||
for (int t = 0; t < texCount; t++) {
|
||||
PTexture tex = texturesArray[t];
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL11.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
gl.glClientActiveTexture(GL11.GL_TEXTURE0 + t);
|
||||
gl.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
@@ -6928,13 +6946,13 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
for (int t = 0; t < texCount; t++) {
|
||||
PTexture tex = texturesArray[t];
|
||||
gl.glActiveTexture(GL11.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
gl.glClientActiveTexture(GL11.GL_TEXTURE0 + t);
|
||||
gl.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
for (int t = 0; t < texCount; t++) {
|
||||
PTexture tex = texturesArray[t];
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
}
|
||||
gl.glDisableClientState(GL11.GL_NORMAL_ARRAY);
|
||||
@@ -7386,6 +7404,22 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
gl11xp = null;
|
||||
}
|
||||
|
||||
if (!glParamsRead) {
|
||||
getGLParameters();
|
||||
}
|
||||
|
||||
// TODO: Check this:
|
||||
// Any remanining resources are deleted now, so we (re) start
|
||||
// from scratch.
|
||||
// Since this method is only called when the sketch starts or
|
||||
// when the screen changes orientation (always before the sketch's
|
||||
// setup() method is triggered) then this seems to be the best
|
||||
// location to release resources. Also, at this point we are
|
||||
// guaranteed to have all the gl objects non-null.
|
||||
//deleteAllGLResources();
|
||||
}
|
||||
|
||||
protected void getGLParameters() {
|
||||
OPENGL_VENDOR = gl.glGetString(GL10.GL_VENDOR);
|
||||
OPENGL_RENDERER = gl.glGetString(GL10.GL_RENDERER);
|
||||
OPENGL_VERSION = gl.glGetString(GL10.GL_VERSION);
|
||||
@@ -7459,15 +7493,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_UNITS, temp, 0);
|
||||
maxTextureUnits = PApplet.min(MAX_TEXTURES, temp[0]);
|
||||
|
||||
// TODO: Check this:
|
||||
// Any remanining resources are deleted now, so we (re) start
|
||||
// from scratch.
|
||||
// Since this method is only called when the sketch starts or
|
||||
// when the screen changes orientation (always before the sketch's
|
||||
// setup() method is triggered) then this seems to be the best
|
||||
// location to release resources. Also, at this point we are
|
||||
// guaranteed to have all the gl objects non-null.
|
||||
//deleteAllGLResources();
|
||||
glParamsRead = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,17 +55,19 @@ public class PShape3D extends PShape implements PConstants {
|
||||
|
||||
// ROOT shape properties:
|
||||
|
||||
// STATIC or DYNAMIC
|
||||
protected int glUsage;
|
||||
|
||||
// Number of texture buffers currently in use:
|
||||
protected int numTexBuffers;
|
||||
protected int numTexBuffers;
|
||||
|
||||
// STATIC or DYNAMIC
|
||||
// TODO: vertex, color, normal and texcoord data can potentially have
|
||||
// different usage modes.
|
||||
protected int glUsage;
|
||||
|
||||
// The OpenGL IDs for the different VBOs
|
||||
protected int glVertexBufferID;
|
||||
protected int glColorBufferID;
|
||||
protected int glNormalBufferID;
|
||||
protected int[] glTexCoordBufferID;
|
||||
public int glVertexBufferID;
|
||||
public int glColorBufferID;
|
||||
public int glNormalBufferID;
|
||||
public int[] glTexCoordBufferID;
|
||||
|
||||
// The float buffers (directly allocated) used to put data into the VBOs
|
||||
protected FloatBuffer vertexBuffer;
|
||||
@@ -2371,9 +2373,9 @@ public class PShape3D extends PShape implements PConstants {
|
||||
break;
|
||||
}
|
||||
|
||||
gl.glEnable(tex.getGLTarget());
|
||||
gl.glEnable(tex.glTarget);
|
||||
gl.glActiveTexture(GL10.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), tex.getGLID());
|
||||
gl.glBindTexture(tex.glTarget, tex.glID);
|
||||
renderTextures[numTextures] = tex;
|
||||
numTextures++;
|
||||
} else {
|
||||
@@ -2451,11 +2453,11 @@ public class PShape3D extends PShape implements PConstants {
|
||||
for (int t = 0; t < numTextures; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glActiveTexture(GL10.GL_TEXTURE0 + t);
|
||||
gl.glBindTexture(tex.getGLTarget(), 0);
|
||||
gl.glBindTexture(tex.glTarget, 0);
|
||||
}
|
||||
for (int t = 0; t < numTextures; t++) {
|
||||
PTexture tex = renderTextures[t];
|
||||
gl.glDisable(tex.getGLTarget());
|
||||
gl.glDisable(tex.glTarget);
|
||||
}
|
||||
if (pointSprites) {
|
||||
gl.glDisable(GL11.GL_POINT_SPRITE_OES);
|
||||
|
||||
@@ -48,16 +48,15 @@ public class PTexture implements PConstants {
|
||||
protected PGraphicsAndroid3D a3d;
|
||||
protected GL10 gl;
|
||||
|
||||
protected int glID;
|
||||
protected int glTarget;
|
||||
protected int glFormat;
|
||||
protected int glMinFilter;
|
||||
protected int glMagFilter;
|
||||
protected int glWrapS;
|
||||
protected int glWrapT;
|
||||
|
||||
protected int glWidth;
|
||||
protected int glHeight;
|
||||
public int glID;
|
||||
public int glTarget;
|
||||
public int glFormat;
|
||||
public int glMinFilter;
|
||||
public int glMagFilter;
|
||||
public int glWrapS;
|
||||
public int glWrapT;
|
||||
public int glWidth;
|
||||
public int glHeight;
|
||||
|
||||
protected boolean usingMipmaps;
|
||||
protected float maxTexCoordU;
|
||||
@@ -399,82 +398,12 @@ public class PTexture implements PConstants {
|
||||
|
||||
// Get OpenGL parameters
|
||||
|
||||
|
||||
protected int getGLWidth() {
|
||||
return glWidth;
|
||||
}
|
||||
|
||||
|
||||
protected int getGLHeight() {
|
||||
return glHeight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides the ID of the OpenGL texture object.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLID() {
|
||||
return glID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture target.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLTarget() {
|
||||
return glTarget;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture internal format.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLFormat() {
|
||||
return glFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture minimization filter.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLMinFilter() {
|
||||
return glMinFilter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the texture magnification filter.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLMagFilter() {
|
||||
return glMagFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture wrapping mode for the S coordinate.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLWrapS() {
|
||||
return glWrapS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture wrapping mode for the T coordinate.
|
||||
* @return int
|
||||
*/
|
||||
protected int getGLWrapT() {
|
||||
return glWrapT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true or false whether or not the texture is using mipmaps.
|
||||
* @return boolean
|
||||
*/
|
||||
protected boolean usingMipmaps() {
|
||||
public boolean usingMipmaps() {
|
||||
return usingMipmaps;
|
||||
}
|
||||
|
||||
@@ -483,7 +412,7 @@ public class PTexture implements PConstants {
|
||||
* Returns the maximum possible value for the texture coordinate U (horizontal).
|
||||
* @return float
|
||||
*/
|
||||
protected float getMaxTexCoordU() {
|
||||
public float getMaxTexCoordU() {
|
||||
return maxTexCoordU;
|
||||
}
|
||||
|
||||
@@ -492,7 +421,7 @@ public class PTexture implements PConstants {
|
||||
* Returns the maximum possible value for the texture coordinate V (vertical).
|
||||
* @return float
|
||||
*/
|
||||
protected float getMaxTexCoordV() {
|
||||
public float getMaxTexCoordV() {
|
||||
return maxTexCoordV;
|
||||
}
|
||||
|
||||
@@ -501,7 +430,7 @@ public class PTexture implements PConstants {
|
||||
* Returns true if the texture is flipped along the horizontal direction.
|
||||
* @return boolean;
|
||||
*/
|
||||
protected boolean isFlippedX() {
|
||||
public boolean isFlippedX() {
|
||||
return flippedX;
|
||||
}
|
||||
|
||||
@@ -510,7 +439,7 @@ public class PTexture implements PConstants {
|
||||
* Sets the texture as flipped or not flipped on the horizontal direction.
|
||||
* @param v boolean;
|
||||
*/
|
||||
protected void setFlippedX(boolean v) {
|
||||
public void setFlippedX(boolean v) {
|
||||
flippedX = v;
|
||||
}
|
||||
|
||||
@@ -519,7 +448,7 @@ public class PTexture implements PConstants {
|
||||
* Returns true if the texture is flipped along the vertical direction.
|
||||
* @return boolean;
|
||||
*/
|
||||
protected boolean isFlippedY() {
|
||||
public boolean isFlippedY() {
|
||||
return flippedY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user