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";
[tex loadImage:file];
[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];
[obj3D release];
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.
Any suggestions?
Hi qilin, It could be that
Hi qilin,
It could be that your textures are not a power of 2 in size?
The textures work. If I try
The textures work.
If I try to switch from "first.png" to "second.png" the texture "first.png" will show up correct and after switch the object will be black.
Hi, just a quick intrusion in
Hi,
just a quick intrusion in your discussion,
not sure about all the details on the iOS code but just speaking from an Android OpenGL perspective, you should have some OpenGL code like glTexImage2D () which updates the pixels of your texture with a new pixel buffer;