Texture rotation in glsl, opengl.

Hi, how to make a turn around the center of the texture, use glsl + opengl ? In old interface work this code

  glTranslatef(0.5, 0.5, 0);
  glRotatef(90, 0, 0, 1);
  glTranslatef(-0.5, -0.5, 0);

      glTexCoord2d(0.0, 1.0);  glVertex2d(x1, y1);
      glTexCoord2d(0.0, 0.0);  glVertex2d(x2, y2);
      glTexCoord2d(1.0, 0.0);  glVertex2d(x3, y3);
      glTexCoord2d(1.0, 1.0);  glVertex2d(x4, y4);

In new interface i use matrix, but work only then x = y, then x != y texture resized.

Matrix4 m1;

m1.rotate(90, 0,0,1);

Only 1 matrix, how rotate picture in original size? Rotate in z axis.

This looks about right. If texture is scaled then you are rotating around the wrong axis, but 90 degrees would make it zero width so that’s not it.

Try LoadIdentity() on teh texture stack first and then change matrixmode back to GL_MODELVIEW when done.
Also try translate -.5 then rotate then +.5 instead of the other way around.

Note that this will rotate the texture on your quad but that texture will clip and clamp/repeat due to rasterization on the quad for anything other than 90 degree increments.

Note that you are not rotating around the Z axis you are rotating around the r axis in tangent space.

OK I think you are saying the old stuff worked and the new stuff doesn’t…?

Well to that I say that you are rotating about the origin, not the 0.5 0.5 center.
Also your software math library would have to be compatible with your gl shaders and take angles in degrees (usually they take quaternions).
Just because you have one matrix does not mean you are restricted to making one software call to set up that matrix.