You need to adjust the rotation matrix. Depending on what you want, convert the coordinates of the vertices or the coordinates of the texture to the rotation matrix in the vertex shader.
Create a vertex shader as follows:
attribute vec3 texPosition; .... uniform mat4 u_rotateMat44; void main() { .... vec4 rotPos = u_rotateMat44 * vec4(texPosition, 1.0); gl_Position = rotPos; }
or that:
attribute vec2 texCoord; .... varying vec2 outTexCoord: uniform mat4 u_rotateMat44; void main() { .... vec4 rotCoord = u_rotateMat44 * vec4(texCoord, 0.0, 1.0); outTexCoord = rotCoord.st; .... }
The rotation matrix can be configured as follows:
#include <math.h> // sin, cos
float ang_rad ....; // angle in radians float rotMat[16] = { cos(ang_rad), sin(ang_rad), 0.0f, 0.0f, -sin(ang_rad), cos(ang_rad ), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f };
Install the glUniformMatrix4fv uniform:
GLuint program = ....;
source share