elastic line

excuse me for my english
how do i need for create an elastic line
“a la autocad”


The best way I’ve found avoids OpenGL entirely… you can use low-level drawing commands to draw an XOR box on the screen from the original position that the user clicked the mouse to the current cursor position. When you draw the box, first draw the last box you drew over again (the XOR function will then “erase” the old box without the expense of a full redraw), then draw the new box.


or you can draw it in OpenGL with XOR logic operation:

glEnable( GL_COLOR_LOGIC_OP );
glLogicOp( GL_XOR );

And, of course, you have to draw it into front buffer:
glDrawBuffer( GL_FRONT );