Render to texture problem or problem in approach

Hello, I’m new to OpenGL and i’m facing an issue in either my code or my approach, need a little help.

What i’m using: I’m using OpenGL ES2 with C++ which is run on both Android and iOS

What i’m trying: I’m trying to make a drawing board application. My approach is to just draw small triangles in my drawing path and leaving them there. Each new line draws more triangles but i never clear. So they key point here is that i dont keep a track my previously drawn vertices. But they need to appear where i left them persistently(Until something redraws on top of it).

What the issue is: When the buffer swap, the screen flickers, because apparently one draw call draws to one buffer and the next draws to the next and the content isnt same on them as well. I tried disabling buffer swapping (in android + iOS) by making buffers persistent but android gives trouble and it a lot of devices dont stop the swapping. So i need to overcome this issue from C++.

What my current solution/approach is: I tried to Render to Texture but it also appears to be failing on a real device, could it be my code is wrong? The reasoning in my mind is that since all of my drawings will go to a single texture(which is used as a buffer as well), it would be persistent across all buffers, so even if they swap, it would appear without any flickering of any sort.

My first question is, is this approach correct? If not how should i tackle it? (What things should i learn as well?)

Second question depends on if my approach is correct; is my code correct?

Here is how i make the Render Texture and set it to be used.
[NOTE]GLuint FramebufferName = 0;
glGenFramebuffers(1, &FramebufferName);
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);

// The texture we're going to render to
GLuint renderedTexture;
glGenTextures(1, &renderedTexture);

// "Bind" the newly created texture : all future texture functions will modify this texture
glBindTexture(GL_TEXTURE_2D, renderedTexture);

// Give an empty image to OpenGL ( the last "0" )
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, _Width, _Height, 0,GL_RGBA, GL_UNSIGNED_BYTE, 0);

// Poor filtering. Needed !
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //GL_NEAREST

// Set "renderedTexture" as our colour attachement #0
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderedTexture, 0);

// Always check that our framebuffer is ok
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
    return false;

glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);[/NOTE]

My shaders basically just take position and color attributes, assign the position and in the fragment shader assign the gl_FragColor. Do i need to make any change in this as well? Reading up tutorials i havent seen (or missed it) that i have to output a texture2d() to the gl_FragColor. They just say draw as usual.

What if i render to texture(assuming my code works)… but then display that texture on screen on a quad? So i can display a quad with a set pair of vertices which can be displayed on everyframe… So buffer swapping wont bother me at all as well.

Can someone give any feedback or tips on this? Will it work?

Yes, this is how a “paint” program should be implemented.

The contents of the default framebuffer aren’t guaranteed to persist from one frame to the next. The contents of the back buffer are undefined after a buffer swap, while the contents of the front buffer can be damaged by overlapping windows or similar. So if you want a framebuffer whose contents aren’t changed by anything other than OpenGL rendering commands, you need to use a framebuffer object.