31
Support / Texture reloading just turns objects white
« on: October 15, 2012, 04:23:37 pm »
Same voxel engine as the last thread I made.
All I'm trying to do is implement saving and loading.
Saving works, a little slower than I had expected, but at least outputs files in .png with ARGB.
Loading the textures for all the layers of voxels only works the first time when I run this method:
The second time I run it, all the objects those textures apply to are just plain white. D:
What is going wrong then? What should I be doing?
NOTE:
I tried using replaceTexture but all that did was replace it then reload it from the first instance it loaded the second I tried editing... So I thought I'd go down a more manual route and it's just getting me to an obvious error I can recreate than the glitchy replacement problems replaceTexture was giving me.
Haaaaaaaalp (plz)
All I'm trying to do is implement saving and loading.
Saving works, a little slower than I had expected, but at least outputs files in .png with ARGB.
Loading the textures for all the layers of voxels only works the first time when I run this method:
Code: [Select]
private void loadWorld(String name)
{
System.out.println("Loading "+name);
// Load each layer image
for(int i=0;i<layerNumber;i++)
{
Texture t=new Texture("user/"+name+"/layer"+i+".png",true);
Texture t2=new Texture("user/"+name+"/layer"+i+".png",true);
t.setGLFiltering(false);
tm.removeTexture("layer"+i);
tm.removeTexture("layerg"+i);
tm.addTexture("layer"+i,t);
tm.addTexture("layerg"+i,t2);
ids[i]=tm.getTextureID("layer"+i);
idgs[i]=tm.getTextureID("layerg"+i);
layers[i]=new TextureInfo(ids[i]);
layers[i].add(tm.getTextureID("floorTexN"),TextureInfo.MODE_MODULATE);
layergs[i]=new TextureInfo(idgs[i]);
pics[i]=Toolkit.getDefaultToolkit().getImage("user/"+name+"/layer"+i+".png");
}
System.out.println("Loaded "+name);
}
(ids and idgs, are just for storing the layer IDs for faster editing elsewhere (so it's not searching for strings))The second time I run it, all the objects those textures apply to are just plain white. D:
What is going wrong then? What should I be doing?
NOTE:
I tried using replaceTexture but all that did was replace it then reload it from the first instance it loaded the second I tried editing... So I thought I'd go down a more manual route and it's just getting me to an obvious error I can recreate than the glitchy replacement problems replaceTexture was giving me.
Haaaaaaaalp (plz)