PDA

View Full Version : About MRT



Cgor_Cyrosly
10-30-2007, 04:26 AM
HI,everyone
I want to use Cg and FBO for MRT,but I dont know how to use the api function :glFramebufferTextureLayerEXT and glFramebufferTextureFaceEXT

As this(which is right?):


int layer=0;
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT,at tachment,colorTex,0,layer++);
//same attachment

or

glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[0] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[1] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[2] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[3] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[4] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[5] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[6] ,colorTex,0,layer++);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment[7] ,colorTex,0,layer++);
//different attachments
glDrawBuffers(8,attachment);




glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment,0,0);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment,0,1);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment,0,2)
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment,0,3);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment,0,4);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment,0,5);

or


glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment[0],0,0);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment[1],0,1);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment[2],0,2)
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment[3],0,3);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment[4],0,4);
glFramebufferTextureFaceEXT(GL_FRAMEBUFFER_EXT,att achment[5],0,5);



I`s another question:when use the ping-pang technology with FBO,I changed the renderering target in the next pass of the loop used:

I setted the FBO before the loop


glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fboIdx);
//used glFramebufferTexture2DEXT for testing again(and as the same result)
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][0],colorTexIdx[dst][0],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][1],colorTexIdx[dst][1],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][2],colorTexIdx[dst][2],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][3],colorTexIdx[dst][3],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][4],colorTexIdx[dst][4],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][5],colorTexIdx[dst][5],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][6],colorTexIdx[dst][6],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[dst][7],colorTexIdx[dst][7],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][0],colorTexIdx[src][0],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][1],colorTexIdx[src][1],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][2],colorTexIdx[src][2],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][3],colorTexIdx[src][3],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][4],colorTexIdx[src][4],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][5],colorTexIdx[src][5],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][6],colorTexIdx[src][6],0);
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT,COLOR[src][7],colorTexIdx[src][7],0);
transferSourceTexture();
CHECK_FRAMEBUFFER_STATUS();




for(int s=0;s<loopDepth;s++){
glDrawBuffers(8,COLOR[dst]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][0]);
glUniform1i(samplerLoc[0],0);
glFinish();
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][1]);
glUniform1i(samplerLoc[1],1);
glFinish();
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][2]);
glUniform1i(samplerLoc[2],2);
glFinish();
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][3]);
glUniform1i(samplerLoc[3],3);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][4]);
glUniform1i(samplerLoc[4],4);
glFinish();
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][5]);
glUniform1i(samplerLoc[5],5);
glFinish();
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][6]);
glUniform1i(samplerLoc[6],6);
glFinish();
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D,colorTexIdx[src][7]);
glUniform1i(samplerLoc[7],7);
glFinish();
glBegin(GL_QUADS);
glMultiTexCoord2f(GL_TEXTURE0,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE1,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE2,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE3,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE4,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE5,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE6,.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE7,.0 ,.0 );
glVertex2f(.0 ,.0 );
glMultiTexCoord2f(GL_TEXTURE0,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE1,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE2,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE3,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE4,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE5,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE6,sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE7,sizeX,.0 );
glVertex2f(sizeX,.0 );
glMultiTexCoord2f(GL_TEXTURE0,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE1,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE2,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE3,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE4,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE5,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE6,sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE7,sizeX,sizeY);
glVertex2f(sizeX,sizeY);
glMultiTexCoord2f(GL_TEXTURE0,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE1,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE2,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE3,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE4,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE5,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE6,.0 ,sizeY);
glMultiTexCoord2f(GL_TEXTURE7,.0 ,sizeY);
glVertex2f(.0 ,sizeY);
glEnd();
glFinish();
dst^=src;
src^=dst;
dst^=src;
}

why not effect only the first pass of loop
thanks!