I am using the code in jmetest.util.JMESWTTest.MyImplementor as my graphics model. I load it from file and display it in an RCP editor window in my app. The first time I open an editor the rotating monkey cube is fine. Subsequent openings show the rotating cube, with random colors, but no textures.
After tracing through the code for a while it seems that the first instance of the model loads the monkey texture and puts it in the cache (i.e. com.jme.scene.state.lwjgl.LWJGLTextureState.load(int)). Subsequent instances of the model recognize that the monkey texture has already been loaded and simply call a "bind" (i.e. GL11.glBindTexture(int target, int texture)). However, this fails to make the texture appear.
If, however, I call TextureManager.clearCache() before instantiating the model then the textures always appear. So, my conclusion is that something about the texture cache is broken.
The critical code which detects the cache hit and calls the bind is in com.jme.scene.state.lwjgl.LWJGLTextureState…
if (texture.getTextureId() == 0) {
// texture not yet loaded.
// this will load and bind and set the records...
load(i);
if (texture.getTextureId() == 0)
continue;
} else {
// texture already exists in OpenGL, just bind it if needed
if (!unitRecord.isValid()
|| unitRecord.boundTexture != texture
.getTextureId()) {
checkAndSetUnit(i, record);
GL11.glBindTexture(getGLType(type), texture
.getTextureId());
if (Debug.stats) {
StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1);
}
unitRecord.boundTexture = texture.getTextureId();
}
}
Note that texture.getTextureId() is always 2, unitRecord.isValid() is always false, and unitRecordBoundTexture is always -1, which means that the cache is hit (as per the code comments) and the bind -- and only the bind -- is called.