diff --git a/android/core/src/processing/core/PGraphicsAndroid3D.java b/android/core/src/processing/core/PGraphicsAndroid3D.java index 48f54047f..342ed261c 100644 --- a/android/core/src/processing/core/PGraphicsAndroid3D.java +++ b/android/core/src/processing/core/PGraphicsAndroid3D.java @@ -2331,7 +2331,7 @@ public class PGraphicsAndroid3D extends PGraphics { PImage[] images = faceTextures[j]; if (1 < numMultitextures) { - for (int t = 0; t < numMultitextures; t++) + for (int t = 0; t < numMultitextures; t++) { if (images[t] != null) { PTexture tex = images[t].getTexture(); if (tex != null) { @@ -2341,8 +2341,10 @@ public class PGraphicsAndroid3D extends PGraphics { renderTextures[numTextures] = tex; numTextures++; } else { - // Null PTexture field in A3D? no good! - throw new RuntimeException("A3D: missing image texture"); + // Null PTexture field in A3D. It can happen and things still ok + // when, for example, a PImage is being loaded asynchronously and + // used for drawing in the meantime... + break; } } else { // If there is a null texture image at some point in the @@ -2351,6 +2353,7 @@ public class PGraphicsAndroid3D extends PGraphics { // the user, anyways. break; } + } } else if (images[0] != null) { PTexture tex = images[0].getTexture(); if (tex != null) { @@ -2359,9 +2362,6 @@ public class PGraphicsAndroid3D extends PGraphics { gl.glBindTexture(tex.getGLTarget(), tex.getGLID()); renderTextures[0] = tex; numTextures = 1; - } else { - // Null PTexture field in A3D? no good! - throw new RuntimeException("A3D: missing image texture"); } } diff --git a/android/core/src/processing/core/PImage.java b/android/core/src/processing/core/PImage.java index a6669a4c4..161eacc01 100644 --- a/android/core/src/processing/core/PImage.java +++ b/android/core/src/processing/core/PImage.java @@ -198,6 +198,7 @@ public class PImage implements PConstants, Cloneable { public void loadTexture() { + if (width == 0 || height == 0) return; if (texture == null) { texture = new PTexture(parent, width, height, new PTexture.Parameters(format)); } @@ -210,6 +211,7 @@ public class PImage implements PConstants, Cloneable { public void loadTexture(int filter) { + if (width == 0 || height == 0) return; if (texture == null) { texture = new PTexture(parent, width, height, new PTexture.Parameters(format, filter)); } @@ -222,6 +224,7 @@ public class PImage implements PConstants, Cloneable { public void loadTexture(PTexture.Parameters params) { + if (width == 0 || height == 0) return; if (texture == null) { texture = new PTexture(parent, width, height, params); } @@ -265,6 +268,7 @@ public class PImage implements PConstants, Cloneable { protected void reloadTexture() { + if (width == 0 || height == 0) return; if (texture != null) { texture = new PTexture(parent, width, height, texture.getParameters()); } @@ -345,7 +349,7 @@ public class PImage implements PConstants, Cloneable { if (bitmap != null) { bitmap.getPixels(pixels, 0, width, 0, 0, width, height); } - if (parent.g.is3D()) { + if (parent.g.is3D() && 0 < width && 0 < height) { if (texture == null) { texture = new PTexture(parent, width, height, new PTexture.Parameters(format)); } diff --git a/android/core/src/processing/core/PShape3D.java b/android/core/src/processing/core/PShape3D.java index 4b36e2a36..82e2c682e 100644 --- a/android/core/src/processing/core/PShape3D.java +++ b/android/core/src/processing/core/PShape3D.java @@ -1719,8 +1719,10 @@ public class PShape3D extends PShape implements PConstants { renderTextures[numTextures] = tex; numTextures++; } else { - // Null PTexture field in A3D? no good! - throw new RuntimeException("A3D: missing image texture"); + // Null PTexture field in A3D. It can happen and things still ok + // when, for example, a PImage is being loaded asynchronously and + // used for drawing in the meantime... + break; } } else { break;