I found that a simple fragment shader for that would be something like:
uniform sampler2D Mtexture;
void main()
{
vec4 color = texture2D(Mtexture, gl_TexCoord[0].st);
gl_FragColor = vec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a);
}
And the OGL code:
glUseProgram(prog);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glColor4f(1, 1, 1, 1);
glBindTexture(GL_TEXTURE_2D, tex);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2i(0,0);
glTexCoord2f(1.0f, 1.0f); glVertex2i(width,0);
glTexCoord2f(1.0f, 0.0f); glVertex2i(width,height);
glTexCoord2f(0.0f, 0.0f); glVertex2i(0,height);
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glUseProgram(0);
However, it's not giving me the expected results, and this is driving me crazy.
Should I disable GL_BLEND before applying the filter? Case not, which function to use?
Should I clear my texture before using a shader on it? <-- Never understood this