"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

create texturer dynamically

HI dude

     I have to make  the texture  dynamically .

    i tried to do this with the help of this link   : https://developer.vuforia.com/forum/faq/android-how-do-i-add-textures-my-model

    but  i am getting black texture .

 

 

 

 JNIEXPORT void JNICALLJava_com_adstuck_times_iar_VideoPlayback_createGLTextureNative(                                                    JNIEnv* env, jobject obj, jobject textureObjectNew){    if (textureObjectNew != NULL)    {         myTexture = Texture::create(env, textureObjectNew);        glGenTextures(1, &(myTexture->mTextureID));        glBindTexture(GL_TEXTURE_2D, myTexture->mTextureID);        // if ( myTexture->mTextureID != NULL)        {        LOG("texture is not nulllllllll   =======================>");    //  here i got the print statement.        }        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);        LOG("dynamic texture created   ############################");  // here i got the print statement       }} but when i use it ............... void renderTransitionTo2D(){ checkRender=false; if (startTransition3Dto2D){ // Starts the Transitiontransition3Dto2D->startTransition(transitionDuration, false, true);LOG("if startTransition3Dto2D is true-------------------------------->");// Initialize control state variablesstartTransition3Dto2D = false; }else{ //if (textures[0]->mTextureID != 0 )//if ( myTexture->mTextureID != NULL){ transition3Dto2D->render(projectionMatrix, pose, myTexture->mTextureID);     // hete i used it as a texture LOG("if startTransition3Dto2D is false-------------------------------->");// check if transition is finishedif (transition3Dto2D->transitionFinished() ){isShowing2DOverlay = true; }}}  finally i got black texture.. pls help......

And the moment i posted question, i found the answer :)

Just changing this line was enough to make it all work.

Thanks a lot :)
 

          currentTextureObject = env->NewGlobalRef(textureObj);

CarterBao

Sat, 08/13/2016 - 10:10

Hi! I just solved this problem and I'd like to share my methods with you. The key problem is not about the texture size( it doesn't need to be size of power of 2).