I'm having problems changing the loaded textures dynamically.
My project is based on image targets.
I need different textures loaded based on marker. I cannot load all textures, that will use alot of memory.
If I load the textures on start they show ok:
for (int i = 0; i < nTextures; ++i)
[textureList addObject: [NSString stringWithUTF8String:textureFilenames[i]]];
If I detect another marker I want to change textures (simplified code, just changing one texture but same problem)
Texture *tex = [[[Texture alloc] init] autorelease];
NSString *file = @"newtextureimage.png";
[textures replaceObjectAtIndex:0 withObject:tex];
Object3D *obj3D = [[Object3D alloc] init];
obj3D.numVertices = NUM_PLANE_VERTEX;
obj3D.vertices = planeVertices;
obj3D.normals = planeNormals;
obj3D.texCoords = planeTexCoords;
obj3D.numIndices = NUM_PLANE_INDEX;
obj3D.indices = planeIndices;
obj3D.texture = [textures ObjectAtIndex:0];
[objects3D replaceObjectAtIndex:0 withObject:obj3D];
After texture is changed the object is all black.
The texture is known good. If I try to change in reverse order the texture is ok and after change black.