drawing using xor

Hi,

Can someone give me some insight of how to draw xor lines using opengl? A xor line is a line used for cursor positioning, where xor’ing two times the same place returns to the original colors.

thanks

guich

You could use:

glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
DrawIt();
glDisable(GL_COLOR_LOGIC_OP);

You might want to check the “Logical Operation” section of the spec first before using it though.

If you’re trying to erase the old drawing by drawing over it a second time, it sounds like you aren’t using double buffering, which you probably should be. Also, XOR-ing some colors can be hard to distinguish (or look ugly). For example if you are XOR-ing a background which has values near the middle of the number range (eg. color=(132,132,132)) against white (255,255,255), you will end up with (123,123,123) so your marker will be hard to distinguish.

Interestingly it appears there was also a patent covering drawing in this way (xor-ing two times to erase), which helped cause Commodore Amiga to go bankrupt: https://plus.google.com/110412141990454266397/posts/dbipY1GJoGv but it should have expired by now.