Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - LoTan

Pages: [1]
1
Support / TextureManager serializing state problem
« on: February 23, 2014, 10:36:24 pm »
I am attempting to serialize the texture manager's state to disk and then reload it at another time.

The following code works as expected and my Object3D renders with the appropriate texture:
Code: [Select]
TextureManager textureManager= TextureManager.getInstance();
textureManager.setState(textureManager.getState());



However, as soon as I serialize this out (I tried files at first, then wrote this code to post here), reload the state, and set it on the texture manager, I get blank/black textures when my object is rendered:

Code: [Select]
TextureManager textureManager = TextureManager.getInstance();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
for (Object state : textureManager.getState()) {
    oos.writeObject(state);
}
oos.writeObject(null); // flag for end of stream when reading in state below
oos.flush();
oos.close();

// restore the texture manager
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
List<Object> state = new ArrayList<Object>();
Object o;
while ( (o = ois.readObject()) != null) {
    state.add(o);
}
textureManager.setState(state);
Log.d("TextureLoader", "Texture names in the texture manager: " + textureManager.getNames());
Log.d("TextureLoader", "Texture count: " + textureManager.getTextureCount());
               

The logcat displays the following message:
Quote
D/TextureLoader﹕ Texture names in the texture manager: [__obj-Color:163/163/163, __obj-Color:0/0/0, --dummy--]
D/TextureLoader﹕ Texture count: 3

So it appears that the textures do load, but nothing renders in the world :(  Is there something I am not doing properly when serializing or deserializing the texture manager state to where it is properly set up?

Help would be truly appreciated.

- LoTan

Pages: [1]