Hi,
I am getting the following error on some low-end to middle-range devices, such as Galaxy Core Prime, Galaxy Grand Prime and Galaxy Ace:
Image width and height cannot be larger than 8064 with this graphics card
Example stack trace:
processing.opengl.Texture.setSize (Texture.java:1159) processing.opengl.Texture.init (Texture.java:203) processing.opengl.Texture. (Texture.java:149) processing.opengl.FontTexture.addTexture (FontTexture.java:126) processing.opengl.FontTexture.initTexture (FontTexture.java:94) processing.opengl.FontTexture. (FontTexture.java:70) processing.opengl.PGraphicsOpenGL.textLineImpl (PGraphicsOpenGL.java:3281) processing.core.PGraphics.textLineAlignImpl (PGraphics.java:3514) processing.core.PGraphics.text (PGraphics.java:3355) processing.core.PApplet.text (PApplet.java:8631)
Looking into processing.opengl.Texture.setSize:
protected void setSize(int w, int h) {
width = w;
height = h;
if (PGraphicsOpenGL.npotTexSupported) {
glWidth = w;
glHeight = h;
} else {
glWidth = PGL.nextPowerOfTwo(w);
glHeight = PGL.nextPowerOfTwo(h);
}
if (glWidth > PGraphicsOpenGL.maxTextureSize ||
glHeight > PGraphicsOpenGL.maxTextureSize) {
glWidth = glHeight = 0;
throw new RuntimeException("Image width and height cannot be" +
" larger than " +
PGraphicsOpenGL.maxTextureSize +
" with this graphics card.");
}
// If non-power-of-two textures are not supported, and the specified width
// or height is non-power-of-two, then glWidth (glHeight) will be greater
// than w (h) because it is chosen to be the next power of two, and this
// quotient will give the appropriate maximum texture coordinate value given
// this situation.
maxTexcoordU = (float)width / glWidth;
maxTexcoordV = (float)height / glHeight;
}
it can be concluded that the error comes from the fact that either glWidth or glHeight is greater than PGraphicsOpenGL.maxTextureSize.
I was wondering if you know what glWidth, glHeight and PGraphicsOpenGL.maxTextureSize mean?
I would guess that PGraphicsOpenGL.maxTextureSize represents the maximum size of the width or height of a texture expressed in pixels. However, if that is the case, I do not understand why the error occurs, since I am definitely not loading any textures that have such a size (at least smaller by a factor of 10). But maybe PGraphicsOpenGL.maxTextureSize means something different?
Also interesting is the fact that PGraphicsOpenGL.maxTextureSize is equal to 8064 on the low-end devices that produce the bug but on better devices it is sometimes twice smaller (4096 on a Nexus 7, for instance), which is counterintuitive (firstly because better devices should be able to process bigger textures and secondly because the exception is thrown for devices whose maxTextureSize is bigger than maxTextureSize of the devices which dont throw the exception bearing in mind that the exception should be less likely to be thrown for devices with higher maxTextureSize, as determined by the if clause preceding the exception throw).
Incidentally, out of 5 devices I have tested (wide range of "quality"), all had a maxTextureSize of 4096. By the way, this number is a power of 2 (2^12), whereas 8064 is not a power of 2 (It happens to be 2^13-2^7, if that even matters).
Any thoughts appreciated!