OpenGL ES rotate texture

Posted by 0xSina on Game Development See other posts from Game Development or by 0xSina
Published on 2012-04-07T14:36:51Z Indexed on 2012/04/07 17:49 UTC
Read the original article Hit count: 272

Filed under:
|
|

I just got started with OpenGL ES... I have a fragment:

const char * sFragment = _STRINGIFY(

                                             varying highp vec2 coordinate;
                                             precision mediump float;

                                             uniform vec4 maskC;
                                             uniform float threshold;
                                             uniform sampler2D videoframe;
                                             uniform sampler2D videosprite;
                                             uniform vec4 mask;
                                             uniform vec4 maskB;


                                             uniform int recording;

                                             vec3 normalize(vec3 color, float meanr)
{
    return color*vec3(0.75 + meanr, 1., 1. - meanr);
}

                                             void main() {
    float d;
    float dB;
    float dC;

    float meanr;
    float meanrB;
    float meanrC;

    float minD;

    vec4 pixelColor;
    vec4 spriteColor;

    pixelColor = texture2D(videoframe, coordinate);
    spriteColor = texture2D(videosprite, coordinate);

    meanr   = (pixelColor.r + mask.r)/8.;
    meanrB  = (pixelColor.r + maskB.r)/8.;
    meanrC  = (pixelColor.r + maskC.r)/8.;

    d   = distance(normalize(pixelColor.rgb, meanr), normalize(mask.rgb, meanr));
    dB  = distance(normalize(pixelColor.rgb, meanrB), normalize(maskB.rgb, meanrB));
    dC  = distance(normalize(pixelColor.rgb, meanrC), normalize(maskC.rgb, meanrC));

    minD = min(d, dB);
    minD = min(minD, dC);

    gl_FragColor = spriteColor;
    if (minD > threshold) {
        gl_FragColor = pixelColor;
    }

}

Now, depending on wether recording is 0 or 1, I want to rotate uniform sampler2D videosprite 180 degrees (reflection in x-axis, flip vertically). How can I do that?

I found the function glRotatef(), but how do i specify that I want to rotate video sprite and not videoframe?

Thanks

© Game Development or respective owner

Related posts about iphone

Related posts about opengl-es