I have texture with semicircle. It should grow clockwise depending on given angle. First, my drawing function prepares vertex and texcoords buffers. Next, it loads rotation matrix and finally texture is drawn. Code looks something like this:
float[] vertexBuffer = {x0, y0, x1, y0, x0, y1, x1, y1};
float[] texCoordBuffer = {0, 0, 1, 0, 0, 1, 1, 1};
float[] matrix = getRotationMatrix(angle); // in Z axis
matrix[12] = (x0 + x1) / 2;
matrix[13] = (y0 + y1) / 2;
gl.glMatrixMode(GL11.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glLoadMatrixf(matrix, 0);
gl.glBindTexture(GL11.GL_TEXTURE_2D, m_TextureID[0]);
gl.glColor4f(1f,1f,1f,1f);
gl.glVertexPointer(2, GL11.GL_FLOAT, 0, vertexBuffer);
gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, texCoordBuffer);
gl.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
I don't have any idea how to crop rotated texture and rotate it back. What is proper way to achieve such effect?