Log in or register to post comments

why object draw as 180 degree rotate?

May 9, 2011 - 1:58am #1

Dear all,

I tried to draw two different opengles square object binding with two image(texture) on two marker. I able to do that. but the problem is two square binding with image drawn as 180 rotate wise. I already use same coding in other openGLES application and it draws two object(square) properly. But here in Qcar, it draw 180 rotate. This is my coding to :

static const float vertices[] = {
-50.0f,-20.0f, 0.0f, //Vertex 0
50.0f, -20.0f, 0.0f, //v50
50.0f, 20.0f, 0.0f, //v2
-50.0f, 20.0f, 0.0f //v3

/** The initial texture coordinates (u, v) */
static const float texture[] = {
//Mapping coordinates for the vertices
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
0.0f, 0.0f

/** The initial indices definition */
static const GLubyte indices[] = {0,1,2,3};

if (!strcmp(trackable->getName(), "stones"))
textureIndex = 0;
thisVertices = vertices;
thisTexCoords = texture;
//thisNormals = teapotNormals;
thisIndices = indices;
const Texture* const thisTexture = textures[textureIndex];


QCAR::Matrix44F modelViewProjection;

SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
&modelViewMatrix.data[0] ,


glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &thisVertices[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &thisTexCoords[0]);

glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
(const GLvoid*) &thisIndices[0]);

Can anyone help to find the problem here. why the square(bind with texture image) drawn 180 rotate....


Re: why object draw as 180 degree rotate?

May 9, 2011 - 11:07pm #3

Thanks Kim,

Your mentioed vertically for y value is working. Now image binded with the square perfectly.

Re: why object draw as 180 degree rotate?

May 9, 2011 - 7:10am #2

Is the image rotated or flipped vertically? Try playing around with the texture coordinates, swap the Y values to flip the image vertically:

0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f

See the Trackables section of the Dev Guide to get an understanding of the QCAR coordinate system.

- Kim

Log in or register to post comments