How to copy a texture with FBO for N times

I want to copy a texture for N times using FBO. Can you give me an example?
How many FBOs do I need to do it?( one FBO with 2 textures attached to it or two FBOs with one texture attached to each of them )

hi,
FBOs enable u offscreen rendering. For copying u can use glCopyTex[Sub]Image2D, glGetTexImage2D etc. or similar functions.

Regards,
Mobeen

I want to use FBO to “render to texture”.
someone at gamedev had asked this question before:
http://www.gamedev.net/community/forums/topic.asp?topic_id=519459

I want to use FBO to “render to texture”.
someone at gamedev had asked this question before:

First, that’s not rendering to a texture. That’s shader-based blending operations. You should only do that if the various blend functions are insufficient for your needs. And that’s semi-rare.

Second, the question was answered quite nicely on the thread you mentioned.

You can see my post in the advanced forum-- The glow effect. The author has used 2 pBuffers. So I want to do the same thing with FBOs.
I want to:
for( int i = 0; i < N; i++ )
{
if( i is even )
{
Bind the first texture of the FBO
render to the second texture of FBO
}
if( i is odd )
{
Bind the socond texture of the FBO
render to the first texture
}
}

BTW, how can I switch between different textures of the FBO?

Hi,
This technique u r referring to is called ping ponging. To accompalish this, you would need to create two attchmts to your fbo. Then in the rendering loop you will do this,

//create two globals
int readID=0, writeID=1;
GLuint texID[2];// color attchmts of FBO

//render func. code
GLenum color_attmts[2]={GL_COLOR_ATTACHMENT0,GL_COLOR_ATTACHMENT1};
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID);
for(int i=0;i<N;i++) {
   glDrawBuffer(color_attmts[writeID]);    
   glUseProgram(progID);
   glActiveTexture(GL_TEXTURE0);
   glBindTexture(GL_TEXTURE2D, texID[readID]);
   glUniform1i(texture_loc, 0);
      DrawFullScreenQuad();
   glUseProgram(0);

   int tmp=readID;
   readID = writeID;
   writeID=tmp;
}

Try this and see if you get what u were looking for.

Regards,
Mobeen