Jacques Giraudel
Jacques Giraudel

Reputation: 512

Texture do not rotate with OpenGL (C)

I am trying to rotate a texture extracted from a video frame (provided by ffmpeg), I have tried the following code :

glTexSubImage2D(GL_TEXTURE_2D,
            0,
            0,
            0,
            textureWidth,
            textureHeight,
            GL_RGBA,
            GL_UNSIGNED_BYTE,
            //s_pixels);
        pFrameConverted->data[0]);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5,0.5,0.0);
glRotatef(90,0.0,0.0,1.0);
glTranslatef(-0.5,-0.5,0.0);
glMatrixMode(GL_MODELVIEW);

//glDrawTexiOES(-dPaddingX, -dPaddingY, 0, drawWidth + 2 * dPaddingX, drawHeight + 2 * dPaddingY);
glDrawTexiOES(0, 0, 0, drawWidth, drawHeight);

The image is not rotated, do you see the problem ?

Upvotes: 0

Views: 172

Answers (1)

Andon M. Coleman
Andon M. Coleman

Reputation: 43319

From the GL_OES_draw_texture extension specification:

Note also that s, t, r, and q are computed for each fragment as part of DrawTex rendering. This implies that the texture matrix is ignored and has no effect on the rendered result.

You are trying to transform the texture coordinates using the fixed-function texture matrix, but like point sprites, those coordinates are generated per-fragment rather than per-vertex. Thus, that means that nothing you do to the texture matrix is ever going to affect the output of glDrawTexiOES (...).

Consider using a textured quad instead, those will pass through the traditional vertex processing pipeline.

Upvotes: 1

Related Questions