Hi,
i think I have found a problem with TextureState.getNumberOfSetTextures().
In my program I need to add texture on the last texture unit and sometimes to remove it. The problem is that every time I add texture, getNumberOfSetTextures() is incremented, but when I remove the last etxture, it is not decrement.
Or maybe I dont understand correctly what getNumberOfSetTextures() is for.
that's a test program :
// first texture
TextureState ts = display.getRenderer().createTextureState();
ts.setEnabled(true);
Texture text = TextureManager.loadTexture(TestBugTexture.class
.getClassLoader().getResource("jmetest/data/images/Monkey.jpg"),
Texture.MM_LINEAR, Texture.FM_LINEAR);
ts.setTexture(text);
ts.getTexture().setWrap(Texture.WM_WRAP_S_WRAP_T);
rootNode.setRenderState(ts);
// second texture
Texture text2 = TextureManager.loadTexture(TestBugTexture.class
.getClassLoader().getResource("jmetest/data/images/Fieldstone.jpg"),
Texture.MM_LINEAR, Texture.FM_LINEAR);
// add 1 texture at the end
int index = ts.getNumberOfSetTextures(); // get next unit
ts.setTexture(text2, index);
System.out.println("index = " + index); // index is 1
// remove texture
ts.removeTexture(text2);
// add 1 texture at the end
index = ts.getNumberOfSetTextures();
System.out.println("index = " + index); // index is 2
ts.setTexture(text2, index);
// remove texture
ts.removeTexture(text2);
// add 1 texture at the end
index = ts.getNumberOfSetTextures();
System.out.println("index = " + index); // index is 3
ts.setTexture(text2, index);
// etc ...
In fact, getNumberOfSetTextures() return texture.size(), but when a texture is removed, texture unit become null in array so "texture" is an array of null elements, growing every time I add new texture.
I use jME1.0 but I have tested with jME 2.0 TextureState and I have the same problem (not a lot of differences).
I think it must return something like "lastTexture" which is update by resetFirstLast(). I have try to return lastTexture instead, but it cause other problems.
Am I wrong or is it a real problem ? And what can be the solution ?
Thanks