Log in or register to post comments

Load texture from web at runtime

January 25, 2013 - 7:47am #1

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

Load texture from web at runtime

January 28, 2013 - 9:47am #4

hi giacomo,

I would sugegst to take a look at this article:

https://developer.vuforia.com/forum/faq/android-how-do-i-add-textures-my-model

This explains step-by-step how to add custom textures, starting from the baseline implementation of ImageTargets sample;

you could try and follow the same approach described there, and then maybe increase the number of textures to more than just 3 or 4 textures and see what happens.

also, make sure to proceed incermentally so to make just a little change at a time and then test it; it is important to narrow down the problem as much as possible.

 

Load texture from web at runtime

January 28, 2013 - 9:41am #3

I have tried but it doesn't work.

i always have the same results.

unfortunately  i'm not skilled in opengl

can you suggest me another way to resolve it?it's so important..

thanks

giacomo

 

Load texture from web at runtime

January 25, 2013 - 8:07am #2

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):

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);

 

 
Could you try that ?
Log in or register to post comments