FBO texture not saving properly

Hello, it’s my first post here so I hope I’ve asked the question in a proper section :wink:

I have a strange problem with textures in FBO, but maybe first the code.

Vertex Shader:

  
varying vec2 coord;  
  
void main(void)  
{  
	coord = gl_Vertex.xy;  
	gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0);  
}  

Fragment Shader:

  
const float PI = 3.141592653589793;  
  
uniform sampler2D tex;  
uniform vec2 center;  
uniform float radius;  
uniform float strength;  
varying vec2 coord;  
  
void main(void)  
{  
	vec4 info = texture2D(tex, coord);  
	float drop = max(0.0, 1.0 - length(center - coord) / radius);  
	drop = 0.5 - cos(drop * PI) * 0.5;  
	info.r += drop * strength;	  
	gl_FragColor = info + vec4(drop, drop, drop, 1.0);  
}  

Program
init

  
  
dropFbo.allocate(screenWidth, screenHeight, GL_RGBA);  
	dropFbo2.allocate(screenWidth, screenHeight, GL_RGBA);  
	dropShader.load("shaders/drop.vert", "shaders/drop.frag");  
	dropFbo.begin();  
	dropPlane.draw();  
	dropFbo.end();  

update on mouse click

  
dropFbo2.begin();  
  
	dropShader.begin();  
	dropFbo.getTextureReference(0).bind();  
	dropShader.setUniform2f("center", posX, posY);  
	dropShader.setUniform1f("radius", radius);  
	dropShader.setUniform1f("strength", strength);  
	  
	dropPlane.draw();  
	dropFbo.getTextureReference(0).unbind();  
	dropShader.end();  
	dropFbo2.end();  
  
	dropFbo.begin();  
	dropFbo2.draw(0, 0);  
	dropFbo.end();  

The problem is as follows. When I render my FBO it has only a red circle representing my last click. It should save between clicks and not clean itself. I look through the code and I’m sure I don’t clear the FBO anywhere, I also don’t render anything else to it. It looks like the texture being bind for the shader is always the same, is not getting update. I don’t have any clue why.

I’m curious why you’re trying to fill data in a texture from one FBO while drawing into another one? Are you trying to do ping-ponging? Just asking since this is the beginners forum, but if you don’t know what ping-ponging is you should check out Mareks post http://www.mazbox.com/node/40 that explains pingponging a bit and has a link to some code.

Yes, that was my first attempt to do a proper ping-pong FBO render. I’ve found some better solutions how to code it better.

I need to pass one texture from previous FBO to the shader, there I use it as a starting parameter array, and write a new one to the second FBO after some calculations. I’m trying to do a interactive water simulation.