PDA

View Full Version : Rubber-band selection



_new_horizon
04-10-2006, 07:28 AM
Hi, I'm trying to implement a rubber-band selection mode in my modelling app.

But I'm not sure how to go about implementing the rect-drawing code. I have the mousedown coordinate, and the current position of the cursor while dragging. I'm thinking that I need to (a)draw the scene as normal, (b)redefine the viewport to use orthographic projection and (c) draw the rectangle. But I don't want to have to redraw the whole scene each time. Any suggestions?

(BTW: I am using compiled display-lists with seperate lists for vertices, polygons and edges).

iris_raj
04-10-2006, 08:31 AM
Dear new_horizon,

The word selection is slightly confusing to me.

Otherwise A simple way to render rubber

1. Get the mouse coordinates of the first and second click and store in array.

2. Refresh the display by rendering a glRect with the coordinates stored in the array as extrem values (x1,y1,x2,y2).
3. 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.



With regards,
RAJESH.R
IRIS,CAIR
Bangalore -1

mikael_aronsson
04-11-2006, 03:48 AM
Yes you render the scene as normal, switch to orthographic mode, setup the modelview matrix to match the window and render the rectangle.

Serge K
04-15-2006, 02:50 AM
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.

shiva
12-30-2011, 12:12 PM
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.