Log in or register to post comments

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

July 3, 2013 - 7:03pm #1

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

Show 2d Pictures which load dynamiclly on IOS device, In video p

July 24, 2013 - 1:43am #6

Thanks for the update!

N

Show 2d Pictures which load dynamiclly on IOS device, In video p

July 23, 2013 - 8:03pm #5

Hi, Nalins,

Sorry for the late reply, yes, it was the 2 texture problem, after I added below code, it works fine.

 

 

glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_SGL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_TGL_CLAMP_TO_EDGE);

 

 

Thanks.

 

Show 2d Pictures which load dynamiclly on IOS device, In video p

July 5, 2013 - 3:36am #4

Glad it is working for you now.

Was it the power of 2 texture problem?

 

N

Show 2d Pictures which load dynamiclly on IOS device, In video p

July 4, 2013 - 10:42pm #3

Nalins,

Thanks, it works now, the reason I'm using the videoplayback sample is because in my mind, the videoplayback sample already has the code of display the image, only has addition codes for play video, it's easy for me to cut some code than add some code, so I'm using the videoplayback sample.

 

Thanks.

Show 2d Pictures which load dynamiclly on IOS device, In video p

July 4, 2013 - 2:40am #2

You may be running into the fact that textures need to be a power of 2 in size.

See this thread for more details:

https://developer.vuforia.com/forum/rendering-opengl-es/changing-texture-plane-object-ios-obligation-square-texture

 

Also, it is not clear why you started with the VideoPlayback sample and deleted the code to play videos?  Staring with Image Targets might have been a better alternative.

 

N

 

Log in or register to post comments