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
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
Show 2d Pictures which load dynamiclly on IOS device, In video p
Nalins,
Show 2d Pictures which load dynamiclly on IOS device, In video p
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
Hi, Nalins,
Sorry for the late reply, yes, it was the 2 texture problem, after I added below code, it works fine.
Show 2d Pictures which load dynamiclly on IOS device, In video p
Thanks for the update!
N