pass a texture to a shader to render on it

I am quite new to shader programming and maybe this question is not really well oriented.

I have a very simple fragment shader to merge rgb info from a texture and alpha info from another:

        "#extension GL_ARB_texture_rectangle : enable \n \  
        uniform sampler2DRect Tex0;\  
        uniform sampler2DRect Tex1;\  
        void main() {\  
            vec4 rgb = texture2DRect(Tex0, gl_TexCoord[0].st);\  
            vec4 alpha = texture2DRect(Tex1, gl_TexCoord[0].st);\  
            gl_FragColor = vec4(rgb.rgb, alpha.a);\  

So I can use it this way:

    shader.setUniformTexture("Tex0", rgb, 0);  
    shader.setUniformTexture("Tex1", alpha, 1);  
    rgb.draw(0, 0);  

What I really want is to have the result also in a texture for further processing, so what I do now is to use an fbo to draw in.

I think it would be much better that the shader could write directly in an output texture but I haven’t been able to find out how to do this.

I’ve seen it is possible to use gl_FragData[] to use different render targets, but I couldn’t find out how to bind an output texture so that the fragmen shader writes on that texture. (I’ve also seen this is deprecated and that things like “out” and “layout” modifiers are used in GLSL 1.3).

Does anybody have any example of how to pass a texture to a shader to render the output on it?