Results 1 to 3 of 3

Thread: how to prevent texture skewness while scaling and rotating

  1. #1

    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?
    Code :
            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);

  2. #2
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: how to prevent texture skewness while scaling and rotati

    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

  3. #3

    Re: how to prevent texture skewness while scaling and rotati

    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.

Similar Threads

  1. Rotating Object about different axis
    By naveen in forum OpenCL
    Replies: 0
    Last Post: 07-29-2011, 01:24 PM
  2. Scaling Texture
    By Rainmaker0929 in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 07-04-2011, 06:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •