I'm new to OpenGL. I'm using Java with LWJGL and Slick. So far I can draw several textures and with buffers I can copy the images shown on the screen to a texture for postprocessing purposes. Using glColor3f() I can make the screen have the desired color (just blue, just red, only show blue and green channels, etc).
But what glColor3f(r, g, b) only does is multiply the values of r, g, b to the current pixels. If R, G, B are the current values of the pixel, what glColor does is (R*r, G*g, B*b) for all pixels.
What I want to do is use the current values R, G, B, so that for example I can swap the red channel for the blue Channel:
(B, R G)
Or use these values and new ones for arithmetic operations
(R+G*r, (B+g)/5, B*0.2)
My purpose is to make a grayscale texture, changing all pixels color (R, G, B) with
color = (R*0.5 + G*0.5 + B*0.5)/3
functionThatChangesColor(color, color, color);
How can I achieve this or something like it?
Thanks!