www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: raft on February 16, 2013, 05:21:38 am

Title: unloading texture
Post by: raft on February 16, 2013, 05:21:38 am
two things:

1. Desktop and AE behaves differently when unloading a texture.
Code: [Select]
TextureManager tm = TextureManager.getInstance();

tm.addTexture("box", new Texture("box.jpg"));
tm.unloadTexture(buffer, tm.getTexture("box"));
tm.addTexture("box", new Texture("box.jpg"));

this code creates an error on desktop, saying texture 'box' has been declared twice. it runs okey on AE

2. on Desktop, after removing/unloading and re-adding, we end up with a white texture
Code: [Select]
TextureManager tm = TextureManager.getInstance();

tm.addTexture("box", new Texture("box.jpg"));
tm.removeAndUnload("box", buffer);
tm.addTexture("box", new Texture("box.jpg"));


Title: Re: unloading texture
Post by: EgonOlsen on February 16, 2013, 09:50:26 am
Two answers: ;)


If you want to replace the content of a texture, use TextureManager.replaceTexture(...) instead.
Title: Re: unloading texture
Post by: raft on February 16, 2013, 10:15:54 am
two+1 more then ;)

1. I guess not. Sky Maze uses that code since the beginning, still same behaviour if I didnt messed up the classpath

2. yes, as you described AE (on nexus 7) also ends up with white textures in this case

2+1. got the message. I should use TextureManager.replaceTexture(..). Indeed that code is in place but was commented out for some forgotten reason

thanks :)
Title: Re: unloading texture
Post by: raft on February 16, 2013, 10:18:25 pm
Quote from: EgonOlsen
I can't reproduce this. Looking into the code, jPCT-AE should raise the same error and in my test, it does. I've no idea why it shouldn't work and it's correct behaviour if it does.

rechecked the code, you are right, AE version checks for texture first, if exists replaces it