"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

How to define the scale of 2D image to display.

I would like to display the 2D image when FrameMarker is detected. My problem is the scale of 2d image isn't like the original file. And I would like to know is it possible to use 2D image file that the size isn't like 256x256 ,256x512.  My code is

 

static const float planeVertices[] =

 

{

    -0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.5, 0.0, -0.5, 0.5, 0.0,

};

 

static const float planeTexcoords[] =

{

    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0

};

 

static const float planeNormals[] =

{

    0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0

};

 

static const unsigned short planeIndices[] =

{

    0, 1, 2, 0, 2, 3

};

 

 

--------------

 

            QCAR::Vec2F targetSize = ((QCAR::ImageTarget *) trackable)->getSize();

            

            QCAR::Matrix44F modelViewProjection;

            

            ShaderUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,

                                             &modelViewMatrix.data[0]);

            ShaderUtils::scalePoseMatrix(targetSize.data[0], targetSize.data[1], 1.0f,

                                         &modelViewMatrix.data[0]);

            ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0],

                                        &modelViewMatrix.data[0] ,

                                        &modelViewProjection.data[0]);

            

            glUseProgram(shaderProgramID);

            

            glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                  (const GLvoid*) &planeVertices[0]);

            glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                  (const GLvoid*) &planeNormals[0]);

            glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,

                                  (const GLvoid*) &planeTexcoords[0]);

            

            glEnableVertexAttribArray(vertexHandle);

            glEnableVertexAttribArray(normalHandle);

            glEnableVertexAttribArray(textureCoordHandle);

            

            glActiveTexture(GL_TEXTURE0);

            glBindTexture(GL_TEXTURE_2D, [obj3D.texture textureID]);

            glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,

                               (GLfloat*)&modelViewProjection.data[0] );

            glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,

                           (const GLvoid*) &planeIndices[0]);