PDA

View Full Version : Improved rubberbanding in opengl?



princeoflightning
02-23-2004, 06:30 AM
Hi, I'm stuck with yet another problem in Opengl.
Here we go-
I need to use rubberbanding in my graphics package that is more or less similar to the Paint Brush app in Windows.
Right now, i've implemented it somewhat like this:
1)Enter XOR mode.
2)Draw the line to display it.
3)And redraw the old line(to erase it) and redraw it(to draw the new line) whenever the mouse motion callback function is invoked.

The code works just fine, but for the flicker when I move the mouse rapidly.

It gets worse for the rectangle, worser for the circle( and ellipse) and worst for the bezier curve (for the bezier I cant just see the curve at certain times.)

The code is similar to F.S. hill Jr' code for rubberbanding.

Ya, I cant afford a SGI workstation until I get a solution for this prob!!

My comp has a TNT2 (AGP) as the graphics accelerator (decelerator!!).
HELP!!!!

Nychold
02-23-2004, 06:51 AM
I don't know much about GLUT, but there are generally two ways to eliminate flicker:

1) redraw only what's needed
2) double buffering or (preffered) page flipping

The second option is often the easiest (and IMHO the best) to implement, but I think GLUT does it automatically. I would try to put a "is rendering" bit in your code (ie: bool isRendering). When you begin to render your frame, simply set that bit, and do not enter any rendering code until that bit is cleared (at the end of your code).

princeoflightning
02-23-2004, 07:00 AM
Yup, ur almost there:
I tried to do double buffering. It works with the animation exmaples that I have: rotating a rectangle when a mouse is clicked.
But whenever I try to do it in my Interactive programs they just dont work: I have to enter fullscreen , but they dont enter into fullscreen mode (I use GLUT for window management).

nexusone
02-23-2004, 12:15 PM
I have an example drawing program that uses rubber banding when drawing object and I do it with glut and double buffering.

It is just how you write your program that makes the diffrence.

If you drop me a e-mail and remind me what your looking for, I will be happy to send you example source for my rubber banding routine.




[This message has been edited by nexusone (edited 02-23-2004).]