Drawing circle like MS-paint (can be visible at the time of dragging from centre )

i am trying to create a paint editor where i can draw circle,line ,ellips using codeblocks(not Visual studio) where language i use is c++/c.
My problem: In my project i try to draw circle like MS-Paint like , When i drag my mouse from a point then circle will be visible in the time of moving the cursor ,Here i need to call the circle algorithm again and again inside of “mouseMoveCircle(int mx,int my) " function :hence i need to call " glClear(GL_COLOR_BUFFER_BIT)” in the next line .
but , for the use of “glClear(GL_COLOR_BUFFER_BIT)” command others object is going to vinish/wash-away which i dont want [example: lets i draw a line , then if i want to draw a circle on the same windows i only able to see only the circle ,the line is cleared as i using “glClear(GL_COLOR_BUFFER_BIT)” command.

how can i get rid from this situation ? am i able to describe my problem ??

void mouseMidpointCircle(int button, int state, int mousex, int mousey)
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)

    x1 = mousex;
    y1 =  480-mousey;


else if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)  //undo(clear)the drawing

    check = 0;


void mouseMoveCircle(int mx,int my)




    glClear(GL_COLOR_BUFFER_BIT);// i need to call this to clear the previous position of circle



Framebuffer objects (FBOs). These allow you to render into a texture.

The system framebuffers (front and back buffer) aren’t persistent. Even if you don’t explicitly clear the back buffer, its contents become undefined whenever you call SwapBuffers.

Thank you very much for your kindly reply.
I have read the article which you provided, but i Don’t understand clearly as i am new in opengl and also there was no complete example for understanding.
Can you provide me, any source code(framebuffer relate) so that i can understand, and finally i can sovle my problem
You can provide me any video tuterial if you have.
NB:i am trying my project in “Codeblocks”

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.