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
{
glClear(GL_COLOR_BUFFER_BIT);
check = 0;
}
}
void mouseMoveCircle(int mx,int my)
{
if(check!=0)
{
x2=mx;
y2=480-my;
CircleMidpoint(x1,y1,x2,y2);
glClear(GL_COLOR_BUFFER_BIT);// i need to call this to clear the previous position of circle
check++;
}
}