TextureArray, accidental image format difference leads to confusing exception

I’ve been playing about with TextureArrays to use as texture maps (as they allow tiling without repeating verticies). Initially it all went very well and I followed the requirements of the texture array (included mainly for google):
Same Size images
Same format images
No more than 512 images

However when I started using texture arrays within a larger application they failed with a confusing exception:
java.lang.IllegalArgumentException: Number of remaining buffer elements is 3072, must be at least 4096. Because at most 4096 elements can be returned, a buffer with at least 4096 elements is required, regardless of actual returned element count

This exception is raised outside of my code (I think in the lwjgl thread) so it didn’t give me an explicit position of the problem but I assumed it was an issue with setting my TexCoord buffer as there was lots of talk of texturedata in the stack trace…

Eventually I found the problem, I had created (lets say) 2 textures, both 'png’s both 32*32 tiles. BUT one has transparent regions (and internally became AGBR8 format) and the other didn’t (and became BGR8 format). This is obviously my fault, I had allowed Paint.Net to automatically choose the format for me, and taken the “Same format images” to mean “both pngs”

So my question is: would it be possible for TextureArray’s constructor to check that all the images are the same format and if not raise an exception there and then (so the problem is relatively obvious). I made this mistake despite reading the requirements, and how many people do that? (ok I read the requirements after I had a problem and I thought I had complied with them).

The code that replicates this problem is below:

[java]package mygame;

import java.util.ArrayList;
import java.util.List;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Caps;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.texture.Image;
import com.jme3.texture.Texture;
import com.jme3.texture.TextureArray;
import com.jme3.util.BufferUtils;

public class TestTextureArray extends SimpleApplication
public void simpleInitApp()
Material mat = new Material(assetManager, “jme3test/texture/UnshadedArray.j3md”);
//Material mat = new Material(assetManager, “Materials/UnshadedArray.j3md”);

   for (Caps caps : renderManager.getRenderer().getCaps()) {
       throw new UnsupportedOperationException("Your hardware does not support TextureArray");

   Texture tex1=assetManager.loadTexture("Textures/glass.png"); //this is a png created within Paint.net that has trasparent regions. AGBR8
   Texture tex2=assetManager.loadTexture("Textures/leaves.png"); //this is a png created within Paint.net that has NO trasparent regions. BGR8
   List image=new ArrayList();
   TextureArray texArray=new TextureArray(image);
   texArray.setWrap(Texture.WrapMode.Repeat); //so we can 'tile'
   mat.setTexture("ColorMap", texArray);
   Mesh m = new Mesh();

   Vector3f[] verticies=new Vector3f[8];
   verticies[0]=new Vector3f(0, 0, 0);
   verticies[1]=new Vector3f(3, 0, 0);
   verticies[2]=new Vector3f(0, 3, 0);
   verticies[3]=new Vector3f(3, 3, 0);
   verticies[4]=new Vector3f(3, 0, 0);
   verticies[5]=new Vector3f(6, 0, 0);
   verticies[6]=new Vector3f(3, 3, 0);
   verticies[7]=new Vector3f(6, 3, 0);
   Vector3f[] texCoOrds=new Vector3f[8];
   texCoOrds[0]=new Vector3f(0, 0, 0); //tiles 3 times in x and y, uses texture 0
   texCoOrds[1]=new Vector3f(3, 0, 0);
   texCoOrds[2]=new Vector3f(0, 3, 0);
   texCoOrds[3]=new Vector3f(3, 3, 0);
   texCoOrds[4]=new Vector3f(0, 0, 1); //does not wrap, uses texture1
   texCoOrds[5]=new Vector3f(1, 0, 1);
   texCoOrds[6]=new Vector3f(0, 1, 1);
   texCoOrds[7]=new Vector3f(1, 1, 1);

   int[] indexes = { 2, 0, 1, 1, 3, 2 , 6, 4, 5, 5, 7, 6};

   m.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(verticies));
   m.setBuffer(Type.TexCoord, 3, BufferUtils.createFloatBuffer(texCoOrds));
   m.setBuffer(Type.Index, 1, BufferUtils.createIntBuffer(indexes));

   Geometry geom = new Geometry("Mesh", m);


public static void main(String[] args)
TestTextureArray app = new TestTextureArray();

}[/java]Interestingly if you put the RGR8 in first and then the AGBR8 you just get ‘mad’ textures for the AGBR8 and the problem is obvious, but the other way round you get this exception. I was just really unlucky that my first texture was AGBR8.

Thanks, it was fixed in SVN