Blend with existing contents of renderbuffer

Hi,

 

I have a renderbuffer which contains all drawing done so far in a drawing application. This renderbuffer is rendered to the screen every frame. When the user paints I render the new brush stroke into the renderbuffer ontop of what already exists.

 

The problem I have is that when rendering into the renderbuffer the blend operation is blending with black as opposed to the current contents of the renderbuffer. I assume this is because the tile rendering has not copied the contents of the renderbuffer into the tile and instead only considers the what it's drawn into the tile this frame.

 

How should I go about ensuring that it can blend with the current contents. I thought I could render the renderbuffer into it'sself as the first operation that frame and then render the blending brush, but felt that there's probably a better way which would mean that the tile would only fetch the pixels it needed from the renderbuffer.

 

Many Thanks

 

Andrew.

 

Hi Andrew,





As long as you are not calling a glClear() operation at the start of your frames, then the hardware should preserve the colour buffer from your previous frame and upload the preserved colour for each tile before your current frame render begins to update the tile/blend with it. Is this how you have implemented your application, or are you attempting to solve the problem in some other way?





If this is the approach you are taking and you are still getting errors, then you may have encountered a bug. If this is the case, can you please let us know some details about your platform, such as the name of the platform (or emulation, if that’s where you’re finding the problem) and the GPU driver version (you should be able to query this with glGetString()).





Thanks,


Joe

Hi Joe,





Thanks for your response. I discovered the issue which lead me to my incorrect post above. We had a bug in our render buffer creation which meant it was ignoring the format and always creating a 32 bit render buffer when I was specifying 16bit. This resulted in an unexpected squaring of any alpha values in the textures I rendered into the render buffer, multiply by Alpha once when they were rendered into the buffer and again when the render buffer was rendered to screen.





It’s good to know that the hardware does copy the contents of the previous render when no glClear() exists.





Thanks





Andrew.