Im trying to draw erasable lines using the XOR method…
ie draw a line in XOR mode, you get a line, then XOR it, it disappears…
But im facing the problem of generation of new colors!! since im XORing, the disppaearing of the old lines is happening, but the new line is of a different color…Is there any way i could solve this?? Heres the code:
void MouseMove(int x,int y)
{
if(FLAG == 0){
X = x;
Y = winh - y;
Xn = x;
Yn = winh - y;
FLAG = 1;
}
else if(FLAG == 1){
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
glBegin(GL_LINES);
glVertex2i(X,Y);
glVertex2i(Xn,Yn);
glEnd();
glFlush();/*Old line erased*/
glBegin(GL_LINES);
glVertex2i(X,Y);
glVertex2i(x, winh - y);
glEnd();
glFlush();
Xn = x;
Yn = winh - y;
}
}
This is my mouse motion callback…Now if the screen is colored to white and if i choose my current drawing color as RED, i get a bluish color due to the XORing…How to overcome this??
I am using the same technique to draw and erase a line. But, even though I am redrawing on a line to erase it, i am not able to erase. What I am getting is a bunch of lines on mouse move. Could anyone tell me the possible reason for it?
Are you drawing exactly over the line to be erased? The technique you are referring to is doing color changing w.r.t background to give you illusion of line deletion.
Perhaps your mouse movement is exactly not over the line and is replacing color of some other portion ;for deletion.
I am drawing exactly over the same line. I am storing the coordinates when drawn, and erasing the old line when the mouse goes to a new point. Has it anything to do with the settings?