"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

Show 2d Pictures which load dynamiclly on IOS device, In video playback sample.

Hi,

I'm coding on videoplayback example, and plan to show the 2d pictures, then I deleted the code refer to play videos and show icons, the picture shows successfully, but, I don't want to load all pictures when the app started, so I'm only load the picture when the rederframe function find a target, but when I finished my change, the picture does not show on the screen, instead of it, there is a black rectangle show on the screen, The code is as below(I have searched the forum about the show 2d pictures , but most of these subject are about the ImageTarget sample, and replace the 3d picture with 2d picture):

 

        const char* myjpgFile = "VuforiaSizzleReel_1.png";

        

        Texture* myTexture = [[Texture alloc] initWithImageFile:[NSString stringWithCString:myjpgFile      encoding:NSASCIIStringEncoding]];

        GLuint textureID;

        glGenTextures(1, &textureID);

        [myTexture setTextureID:textureID];

        

        Texture* t = myTexture;

        

            frameTextureID = [t textureID];

            aspectRatio = (float)[t height] / (float)[t width];

            texCoords = quadTexCoords;

        

        

        // Get the current projection matrix

        QCAR::Matrix44F projMatrix = [[QCARControl getInstance] projectionMatrix];

        

        

            // Convert trackable pose to matrix for use with OpenGL

            QCAR::Matrix44F modelViewMatrixVideo = QCAR::Tool::convertPose2GLMatrix(trackablePose);

            QCAR::Matrix44F modelViewProjectionVideo;

            

            ShaderUtils::translatePoseMatrix(0.0f, 0.0f, videoData[playerIndex].targetPositiveDimensions.data[0],

                                             &modelViewMatrixVideo.data[0]);

            

            ShaderUtils::scalePoseMatrix(videoData[playerIndex].targetPositiveDimensions.data[0], 

                                         videoData[playerIndex].targetPositiveDimensions.data[0] * aspectRatio, 

                                         videoData[playerIndex].targetPositiveDimensions.data[0],

                                         &modelViewMatrixVideo.data[0]);

            

            ShaderUtils::multiplyMatrix(projMatrix.data,

                                        &modelViewMatrixVideo.data[0] ,

                                        &modelViewProjectionVideo.data[0]);

            

            glUseProgram(shaderProgramID);

            

           glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, quadVertices);

            glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, quadNormals);

            

            

            

            glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, texCoords);

             

            

            glEnableVertexAttribArray(vertexHandle);

            glEnableVertexAttribArray(normalHandle);

            glEnableVertexAttribArray(textureCoordHandle);

            

            glActiveTexture(GL_TEXTURE0);

            glBindTexture(GL_TEXTURE_2D, frameTextureID);

            glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjectionVideo.data[0]);

            glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/);

            glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT, quadIndices);

            

            glDisableVertexAttribArray(vertexHandle);

            glDisableVertexAttribArray(normalHandle);

            glDisableVertexAttribArray(textureCoordHandle);

            

            glUseProgram(0);

        

 

        

        ShaderUtils::checkGlError("VideoPlayback renderFrameQCAR");