"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Change texture

 

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?

 

AlessandroB

Mon, 01/14/2013 - 11:17

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;