Get the mouse coordinates of the first and second click and store in array.
Refresh the display by rendering a glRect with the coordinates stored in the array as extrem values (x1,y1,x2,y2).
Before Drawing Ensure that array contains atleast two points.
There are other techniques using glIndexi()
for erasing the viewport(with a background color) and then drawing glRect before using glIndexi(WHITE); Give search in GOOGLE.
Originally posted by _new_horizon: Hi, I’m trying to implement a rubber-band selection mode in my modelling app.
…
But I don’t want to have to redraw the whole scene each time. Any suggestions?
The simplest way to get acceptable result is to draw the rectangle with inversion:
glLogicOp( GL_XOR );
glEnable( GL_COLOR_LOGIC_OP );
// xor-ing with grey produce visible changes on any color
glColor3ub( 128, 128, 128 );
glRect_(…);
To restore previous image just draw the same rectangle again.
Hi I am implementing GL_XOR drawings on front buffer to do interactive drawing on the screen. However, by using this method I am able to draw a line but I am not able to erase it.
To erase a line I am drawing on it again using the GL_XOR mode but it is not erasing. Does anyone know the possible reason forit.