CRenderTexture - How to clear the buffer correctly

Using the latest release 2.0.4 , Im using CRenderTexture to basically load up a “noise” texture, color it and apply a gradient.

So far so good, and it works pretty well, even though the gradient is coming from the wrong direction :frowning:
but the real problem is that it works for the first texture I “decorate”, but the next texture I run through the function below does not look right,

it seems that something is being left in the buffer from the rendering of the first texture, and then that gets added to the second.
I’ve tried and tried to clear the buffer, but nothing i do helps ?

See the attached pic, the top pic is my first texture, and you can see the second textures gradient is messed up(ignore the 9 on the image) ??? Im at a loss.

@
CCTexture2D* TextureTestLayer::decorate(int size, ccColor4F cf, CCSprite * noise)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f,0.0f,0.0f,1.0f);
CCRenderTexture *rt = CCRenderTexture::create(size, size);
rt~~>beginWithClear;
// load up the noise texture
if
{
ccBlendFunc blendFunc = ;
noise~~>setBlendFunc(blendFunc);
noise~~>setPosition);
noise~~>setScale((float)size/size*CC_CONTENT_SCALE_FACTOR());
noise~~>visit;
}
// now add the gradient
float gradientAlpha = 0.5f;
ccVertex2F vertices[4];
ccColor4F colors[4];
int nVertices = 0;
ccVertex2F v1, v2, v3, v4;
ccColor4F color1, color2, color3, color4;
ccVertex2F v1 = vertex2;
ccVertex2F v2 = vertex2;
ccVertex2F v3 = vertex2;
ccVertex2F v4 = vertex2;
color1.r = 0; color1.g = 0; color1.b = 0; color1.a = 0;
color2.r = 0; color2.g = 0; color2.b = 0; color2.a = 0;
color3.r = 0; color3.g = 0; color3.b = 0; color3.a = gradientAlpha;
color4.r = 0; color4.g = 0; color4.b = 0; color4.a = gradientAlpha;
vertices[nVertices] = v1;
colors[nVertices**] = color1;
vertices[nVertices] = v2;
colors[nVertices**] = color2;
vertices[nVertices] = v3;
colors[nVertices**] = color3;
vertices[nVertices] = v4;
colors[nVertices**] = color4;
// adjust vertices for retina
for {
vertices[i].x = CC_CONTENT_SCALE_FACTOR;
vertices[i].y
= CC_CONTENT_SCALE_FACTOR;
}
ccGLEnableVertexAttribs;
setShaderProgram~~>programForKey);
CC_NODE_DRAW_SETUP;

glVertexAttribPointer;
glVertexAttribPointer;
glDrawArraysnVertices);

rt~~>end;
return rt~~>getSprite()->getTexture();
}
@


renderissue.png (49.5 KB)

I have the same issue: did you solve it?