"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

Load texture from web at runtime

hi

i want replace a texture (downloaded from internet) to my plane model at runtime.

i have use the code in the post in https://developer.vuforia.com/forum/faq/android-how-do-i-add-textures-my-model 

 

                

                	Texture* myTexture;

                    myTexture = Texture::create(env, textureObject);
                    glGenTextures(1, &(myTexture->mTextureID));
                    glBindTexture(GL_TEXTURE_2D, myTexture->mTextureID);

                    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
                    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myTexture->mWidth,
                                         myTexture->mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
                                         (GLvoid*) myTexture->mData);
               	textures[15]=myTexture;

 

                                  //replace the old texture with the new texture, 0 is a valid index because at the initilization time i have load 5 image.

                      textures[0]=myTexture;

but when i view the target, the model is black.

NOTE:The image is ok because if i load it at the initialization time i view it correctly on the plane .

is there some advice to resolve it?

thanks

giacomo

AlessandroB

Fri, 01/25/2013 - 16:07

Hi giacomo,

one thing you could try is to use the same texture settings in the _renderFrame function (right after the glBindTexture() that you call when rendering the mesh):