PDA

View Full Version : rubber-banding



pizi
03-09-2002, 12:52 PM
I am trying to implement rubber banding in a mfc/opengl windows xp application. The approach I take is to render with logic op enabled and set to XOR mode.
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
While the rubber banding works, those (such as a cube) rendered already becomes transparent. I wonder if this is an opengl hardware (NVIDIA GeForce2) implementation problem or something is wrong with my coding. The rubber banding does not work if hardware acceleration is disabled. Does anyone have any experience or idea on this?

zeckensack
03-09-2002, 01:44 PM
What you describe sounds exactly like the expected behaviour. While it may not do what you wanted it to do, the problems is not in OpenGL but in your expectations.

pizi
03-09-2002, 03:48 PM
Here is what I did roughly:
1). OnLButtonDown()
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);

2). OnLButtonUp()
glDisable(GL_COLOR_LOGIC_OP);
DrawRubberBandLine();
SwapBuffers(hglDC);

3). OnMouseMove()
DrawRubberBandLine();//draw
SwapBuffers(hglDC);
DrawRubberBandLine();//erase

4). OnPaint()
DrawCube();

My expectation is to do what many CAD (such as AutoCAD) program does when drawing a line. When you issue a line command, you pick a point for one end of a line (action 1) then move the mouse and pick another point for the other end of the line (action 2). Between action 1 and 2, you want to draw rubber band line to give user some drawing clue.

In my program, I want to render a line and then erase it without disturbing what has already been rendered (a 3d cube). Before XOR logic, the cube is drawn and shown (correctly) with hidden faces removed. After XOR logic, however, the same cube is shown (incorrectly) with all faces transparent. Any idea to avoid such a problem is greatly appreciated.