how to prevent texture skewness while scaling and rotating

Hi everyone
I have just started learning opengl es 2.0. This is my code for setting it up to draw. The problem i am facing is that when i rotate some rectangle, the image gets skewed. the height and width of the texture i am using changes. Can someone tell me what i am doing wrong?

	
        glViewport(0,0, (GLint)screenWidth, (GLint)screenHeight);

	     glMatrixMode(GL_PROJECTION);
	     glLoadIdentity();

	     glOrthof(-1,1,-1,1,-1,1);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glPushMatrix();

        glTranslatef(positionX, positionY,0.0f);

        glScalef( -scaleX , -scaleY ,1);

        glRotatef(rotationZ, 0.0f, 0.0f, 1.0f);

Hello,

Your code is OpenGL ES 1.1, not 2.0.

I’m not sure you can use negative values for glScalef()? To scale down you should use values between 0.0f and 1.0f. For example, glScalef(0.5f, 0.5f, 0.5f), will scale down by half.

OpenGL ES always scales the viewing volume to fit the viewport you have defined. You could reduce the screenWidth to equal the screenHeight parameter to glViewport().

Regards, Clay

Hey
Thanks for the reply. I am using negative scale values to invert the image in that case, and it works. So, If i swap the height and widths, will it work for rotating 360 degrees? I mean i will have to swap them at every 45 degrees i guess.
I figured out one way of doing it would be to treat the rectangular image as a sqaure, and first, import it as a square. Second, scale it equally on the x and y axis.

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