By giagi87
on Fri, 01/25/2013 - 15:47
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
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):
Load texture from web at runtime
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
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