   CG shader eval in FBO rendering
  Hi again,so now I have another problem when rendering out to texture using a FBO.Surely I should be able to run a texture through a CG shader even when rendering to FBO-texture!?The result I am getting is texture data in the fbo-textre but that data is not affected by my CG shader.The CG shader works as expected if I render normally to the screen.Can anyone see what I am doing wrong?(Slightly simplified code){Init_FBO_Buffers_and_Texture(); // This has been tested and seems to work.GLClear_and_Set_Viewport();cgGLBindProgram( g_CGprogram_pixel );cgGLEnableProfile( g_CGprofile_pixel );cgGLEnableTextureParameter( g_CGparam_mult );cgGLSetParameter1f( g_CGparam_mult, mult );// Start 'recording'glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFBO);glPushAttrib(GL_VIEWPORT_BIT);GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);if(status != GL_FRAMEBUFFER_COMPLETE_EXT)    printf("FBO Error: %04x\n", (int)status);// Draw flat quad textured by CG shaderglBegin (GL_QUADS);glTexCoord2f (0.0, 1.0);glVertex3f (-1.0, -1.0, 0.0);glTexCoord2f (1.0, 1.0);glVertex3f (1.0, -1.0, 0.0);glTexCoord2f (1.0, 0.0);glVertex3f (1.0, 1.0, 0.0);glTexCoord2f (0.0, 0.0);glVertex3f (-1.0, 1.0, 0.0);glEnd();// Stop recordingglPopAttrib();glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);// Turn off CG shader as result should be in the buffer by now.cgGLDisableProfile( g_CGprofile_pixel );GLClear_and_Set_Viewport();glColor3f(1.0f, 1.0f, 0.0f);glBindTexture (GL_TEXTURE_2D, FBO_RenderBuffer); // Using what I just recordedglBegin (GL_QUADS);glTexCoord2f (0.0, 1.0);glVertex3f (-0.8, -0.8, 0.0);glTexCoord2f (1.0, 1.0);glVertex3f (0.8, -0.8, 0.0);glTexCoord2f (1.0, 0.0);glVertex3f (0.8, 0.8, 0.0);glTexCoord2f (0.0, 0.0);glVertex3f (-0.8, 0.8, 0.0);glEnd();glFlush();SwapBuffers();}(hmmm...am I doing something wrong with the code tags?)Can anyone see what I am doing wrong?cheersfred   
Actually, I'm now pretty sure that the CG shader works with the FBO.I have some other problem.cheersfred   ;  Hello,when you set the fbo as render target you call something like thisglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_Framebuffer);glPushAttrib(SaveAttrib); ////////////////////////////////////////// align viewport////////////////////////////////////////glViewport(0, 0, m_uiWidth, m_uiHeight);////////////////////////////////////////// set active attachment (target)////////////////////////////////////////glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);////////////////////////////////////////// clear buffers////////////////////////////////////////glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); In your code example you call GLClear_and_Set_Viewport();again. But I think you wanted to do something like this.glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);////////////////////////////////////////// pop attribs////////////////////////////////////////glPopAttrib();This gets back your old viewport.What do you mean by your data is not effected by the CG shader ?You disabled the shader before drawing a fullscreenquad with a texture.Try a simple textureing shadervertexprogramstruct data{    float2 texcoord : TEXCOORD0;    float4 position : POSITION;};data main(data Input){   data Output = (data)0;   Output.position = IN.position;   Output.texcoord = IN.texcoord;   return Output;}fragmentprogramstruct data{    float2 texcoord : TEXCOORD0;  };float4 main(data Input, uniform sampler2D texture) : COLOR{    float4 color = tex2D(texture, Input.xy);    return color;}And then activate this shader program before you draw your fullscreen quad.Example. (pseudo code)YourShader.SetUniformParameter(texture);YourShader.Enable();DrawFullscreenQuad();YourShader.Disable();Btw, dont use glFlush(); I guess you set up double buffering. Soyou need SwapBuffers.And Cg works with FBO's...c-mos   ;  Why not use flush??   ;  I suppose he has double buffering enabled. So there is no need to call glFlushbefore glSwapBuffers. For further information you can look athttp://www.opengl.org/wiki/Common_Mistakes#Render_To_Textureand read the part glFlush/glFinishc-mos   