Multi-Texturing using OffscreenRendering & Alpha-Texture...

Hi all!

I’ve got a problem here… I’m using offscreen-rendering to create a graphical output that is then split into 4 areas so that, when displayed on 4 beamers via a quad-head-card, there will be a certain overlapping region for soft-edging.

I thought it would be quite simple to just add an additional texture holding the alpha-mask from an image file and then mapping the dedicated part of the Offscreen-Buffer and the neccessary part of the alpha-map to each of the four target-quads…

My problem now (as with most problems I guess) - it doesn’t work… And worst of all - I don’t really know where I went wrong… (I’ll post some code closer to the bottom)

Texture-Creation from Image-File?
Texture-Binding?
Texture-Combining?

I guess my fault is somewhere in Texture-Creation, for when I use the Offscreen-Buffer as 1. and 2. texture he seems to find the data (well at least it did some time last night - before several changes I cannot really remember) - although I could not test if the shader really takes the values from the second-texture - because both are identical - and in the same memory-area… But it worked when the glsl-fragment-shader was:

uniform sampler2D tex_rgb, tex_a;

void main()
{
vec4 c = texture2D(tex_rgb, gl_TexCoord[0].st);
vec4 c2 = texture2D(tex_a, gl_TexCoord[1].st);
gl_FragColor = vec4(c.rgb,c2.a);
}

and it did not when I used

vec4 c2 = texture2D(tex_a, gl_TexCoord[2].st);

So at least I guess it took the data from the correct place…

Maybe I missed something about texture-coordinate-generation when creating the texture like that (in this case I wanted to use test-values-first):


byte[] g3 = new byte[my_widthmy_height4];
for( int i = 0; i<g3.length;i++)
{
g3[i]=127;
}

    gl = pgl.gl;
    ByteBuffer dest = ByteBuffer.allocateDirect(g3.length);// * BufferUtil.SIZEOF_INT);
    dest.order(ByteOrder.nativeOrder()); 
    dest.put(g3, 0, g3.length);
    dest.rewind();      

gl.glBindTexture(GL.GL_TEXTURE_2D, alph[0]);
	gl.glTexImage2D(GL.GL_TEXTURE_2D,  0, GL.GL_RGBA,my_width,my_height, 0,  GL.GL_RGBA,GL.GL_BYTE, dest);

or


int[] g3 = new int[my_widthmy_height4];
for( int i = 0; i<g3.length;i++)
{
g3[i]=i%255;
}

    gl = pgl.gl;
    ByteBuffer dest = ByteBuffer.allocateDirect(g3.length* BufferUtil.SIZEOF_INT);
    dest.order(ByteOrder.nativeOrder()); 
    dest.asIntBuffer().put(g3, 0, g3.length);
    dest.rewind();      

gl.glBindTexture(GL.GL_TEXTURE_2D, alph[0]);
	gl.glTexImage2D(GL.GL_TEXTURE_2D,  0, GL.GL_RGBA,my_width,my_height, 0,  GL.GL_RGBA,GL.GL_INT, dest);

something else i tried:


g2 = new int[my_widthmy_height4];
for( int i = 0; i<g2.length;i++)
{
g2[i]=i%255;
}

gl.glActiveTexture(GL.GL_TEXTURE1);
gl.glEnable( GL.GL_TEXTURE_2D );

IntBuffer pixBuffer=IntBuffer.wrap(g2);
pixBuffer.rewind();

alph = new int[1];
gl.glGenTextures(1, alph,0);
gl.glBindTexture(GL.GL_TEXTURE_2D, alph[0]);;
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, my_width,my_height, 0, GL.GL_BGRA,GL.GL_UNSIGNED_BYTE, pixBuffer);

but everything to no avail…

I’m not so really sure about the binding-part either:

gl.glActiveTexture(GL.GL_TEXTURE0);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D, pg.getDrawTex());

        gl.glActiveTexture(GL.GL_TEXTURE1);
        gl.glEnable(GL.GL_TEXTURE_2D);
        gl.glBindTexture(GL.GL_TEXTURE_2D, alph[0]);
        	
        gl.glColor4f(1.0, 1.0, 1.0, 1.0);         
        gl.glBegin(GL.GL_QUADS);

              gl.glMultiTexCoord2f(GL.GL_TEXTURE0,0.0, 0.0);
              gl.glMultiTexCoord2f(GL.GL_TEXTURE1,0.0, 0.0);
            gl.glVertex2f(0.0, 0.0);


            gl.glMultiTexCoord2f(GL.GL_TEXTURE0,1.0, 0.0);
            gl.glMultiTexCoord2f(GL.GL_TEXTURE1,1.0, 0.0);
            gl.glVertex2f(width, 0.0);

            gl.glMultiTexCoord2f(GL.GL_TEXTURE0,1.0, 1.0);
            gl.glMultiTexCoord2f(GL.GL_TEXTURE1,1.0, 1.0);
            gl.glVertex2f(width, height);

              gl.glMultiTexCoord2f(GL.GL_TEXTURE0,0.0, 1.0);
            gl.glMultiTexCoord2f(GL.GL_TEXTURE1,0.0, 1.0);
            gl.glVertex2f(0.0, height);
        gl.glEnd();
        
        //gl.glActiveTexture(GL.GL_TEXTURE1);
        gl.glDisable(GL.GL_TEXTURE_2D);
        
        //gl.glActiveTexture(GL.GL_TEXTURE0);
        //gl.glDisable(GL.GL_TEXTURE_2D);

        gl.glBindTexture(GL.GL_TEXTURE_2D, 0);

Now, can anybody help me?

Did I miss something? Some Shifting, Splitting, Swapping, Binding, Blending, Combining or whatsoever?

Any hints, pointers, suggestions or best of course solutions would are appreciated…

Thanks in advance,

Sven