Disappearing textures on second instance of jME

Hi all,

I keep having problems with disappearing textures while extending the "SimpleCanvasImpl" and/or "BaseGame", so you could say i keep having these problems with jME in general.

I am not sure whether I just forget about cleaning up properly or whether it is a bug of jME's or even LWJGL's or OpenGL's.

So, what I did is creating some kind of swing application that covers handling of several parts of my general game setup (for instance I got rid of the typical jME's properties dialog putting that information into my own configuration dialog that covers a little more than only display settings). One of my application's parts is a player model chooser that uses "SimpleCanvasImpl" to display the models. As the models are attached to additional player data I did attach the model display to the player data dialog, which is instantiated and destroyed for each player separately.

As that stuff is still in early development stage, I am using one dummy model and texture for all cases. The thing is… as soon as I open the model display the second time, the model textures are not displayed any more and I only see a white model.

I tried a similar thing for the "BaseGame", setting up a terrain with textures and skybox. As soon as I start that jME application the second time, by creating a new thread on quit(), the skybox textures disappear and are displayed all white, while the terrain's textures look fine.

The easiest way to test that stuff on your own is the following:

  1. take Mojo's flagrush tutorial Lesson4.java and create your own copy
  2. change the class definition like this:

    public class Lesson4 extends BaseGame [u]implements Runnable[/u] {}

  3. change method "quit()" to this:

        protected void quit() {


            new Thread(new Lesson4(), "jMEtextureTest").start();


  4. add this method:

        public void run() {

            Lesson4 app = new Lesson4();

             app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, Lesson4.class





    I know that you could just say, jME is not intended to run twice during one session, but that should be nonsense especially for the "SimpleCanvasImpl". In fact I assume that I am forgetting something like a cleanup. The one thing that really confuses me though is that Lesson4.java from Mojo, which I consider to be a flawless example of jME's usage, results in the same problem as the "SimpleCanvasImpl" does.

    Is it my mistake?

    If yes: How can I fix it?

    If not: Is there any chance that it is fixed soon? Where should I look, to fix it myself?

    PS: Sorry for my English, I am not a native speaker.

I vaguely remember someone had some kind of solution for the same sort of problem (dissappearing textures when using two different context). I think that was renanse? (My guess is you're using TextureLoader, and it's giving you cached textures that are not actually caches, because they're in another context). Can't find the topic right now though…

Yes, Llama, this is caused by the TextureManager caching the texture. Simply call TextureManager.clearCache() in cleanup or before you setup the next display.

Sweet, that works perfectly. Thank you very much, irrisor!