By rassall_jubair
on Wed, 06/20/2012 - 17:04
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];
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(textureCoordHandle);
QCAR::Matrix44F modelViewProjection;
SampleUtils::translatePoseMatrix(0.0f, 0.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);
glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
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] );
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_BYTE,
(const GLvoid*) &thisIndices[0]);
Can anyone help to find the problem here. why the square(bind with texture image) drawn 180 rotate....
Regards
Rassall
Re: why object draw as 180 degree rotate?
Re: why object draw as 180 degree rotate?