private void loadTextures() { mTextures.add(Texture.loadTextureFromApk("banana.jpg", getAssets())); /*mTextures.add(Texture.loadTextureFromApk("TextureTeapotBrass.png", getAssets())); mTextures.add(Texture.loadTextureFromApk("TextureTeapotBlue.png", getAssets())); mTextures.add(Texture.loadTextureFromApk("TextureTeapotRed.png", getAssets()));*/ }
4. Change the code in imageTarget.cpp:
#ifdef USE_OPENGL_ES_1_1 // Load projection matrix: glMatrixMode(GL_PROJECTION); glLoadMatrixf(projectionMatrix.data); // Load model view matrix: glMatrixMode(GL_MODELVIEW); glLoadMatrixf(modelViewMatrix.data); glTranslatef(0.f, 0.f, kObjectScale); glScalef(kObjectScale, kObjectScale, kObjectScale); // Draw object: glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &teapotTexCoords[0]); glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &teapotVertices[0]); glNormalPointer(GL_FLOAT, 0, (const GLvoid*) &teapotNormals[0]); glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]); #else QCAR::Matrix44F modelViewProjection; SampleUtils::translatePoseMatrix(5.0f, 5.0f, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); glUseProgram(shaderProgramID); glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaVerts[0]); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaNormals[0]); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaTexCoords[0]); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glEnableVertexAttribArray(textureCoordHandle); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts); SampleUtils::checkGlError("ImageTargets renderFrame"); #endif
5. I compile with the new ndk.
I follow the steps. Just turn on the camera and took a shine to the marker and hold camera and there is no model.
Hi,
this is a common issue, chances are that the banana is simply too small to be visible;
have you tried increasing kObjectScale variable in ImageTargets.cpp to 100.0f (current value is 3.0f)
?