openglES 3.0 how to keep the texture size when rotate a degree

hi all,
i run my opengl code base on opengles 3.0 window version (opengles3-book-master.zip). i want to roate a texture (this is a needle),
my screen is 1920x720, my needle image is 160x40, when rotate 0 degree the needle is showed normal,
but if rotate any degree which is larger than 0 degree, the needle texture size is not 160x40.
the following is my rotate code:

void rotateTexMvp(ESContext *esContext, GLint layer, GLint texId, GLfloat angle, stPos *pCenterPos)
{
	stUserData *userData = esContext->userData;
	ESMatrix perspective;
	ESMatrix modelview;
	ESMatrix view;
	float    aspect;

	GLfloat center_x = coordinateTrans((GLfloat)pCenterPos->x / userData->winWidth, TEXTURE_TO_SCREEN);
	GLfloat center_y = -1.0f * coordinateTrans((GLfloat)pCenterPos->y / userData->winHeight, TEXTURE_TO_SCREEN);

	// Compute the window aspect ratio
	aspect = (GLfloat)userData->winWidth / (GLfloat)userData->winHeight;

	// Generate a perspective matrix with a 45 degree FOV
	esMatrixLoadIdentity(&perspective);
	//esPerspective(&perspective, 45.0f, aspect, 1.0f, 1.0f);
	esFrustum(&perspective, -aspect, aspect, -1.0f, 1.0f, 1.0f, 1.0f);
	
	// Generate a model view matrix to rotate/translate the cube
	esMatrixLoadIdentity(&modelview);

	// Translate away from the viewer
	esTranslate(&modelview, center_x, center_y, 0.0);

	// Rotate the texture around Z direction
	esRotate(&modelview, -angle, 0.0, 0.0, 1.0);

	// Translate away from the viewer
	esTranslate(&modelview, -center_x, -center_y, 0.0);

	esMatrixLookAt(&view,
		0.0f, 0.0f, 1.0f,   // eye position
		0.0f, 0.0f, 0.0f,	// objection position
		0.0f, 1.0f, 0.0f);	// eye up direction

	esMatrixMultiply(&modelview, &modelview, &view);

	// Compute the final MVP by multiplying the
	// modevleiw and perspective matrices together
	esMatrixMultiply(&userData->texMvpMatrix[layer][texId], &modelview, &perspective);
}

please help me to figure out how to keep the size of texture when rotating. thanks!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.