I am writing a vector drawing program on Linux using Mesa on X-window 4.x
using GTK+ on a gtkglarea.
What I am trying to do is when drawing a primative (point, line etc.) I want the cursor to snap to the closest existing vertex if within a certain distance.
My first thought is to try and use the selection mechanism, but I’m not sure how to proceed. Has any one done this before ?
Currently I am storing my vertex information in a linked list, so it will be eaisily editable.
I do not want to use a X window function, due to portability issues.
I’m not sure if selection is the best way to go. It will give you all the points near the mouse but it won’t tell you which is closest. I have not looked at feedback but it might be the answer. Alternatively you’ll have to use gluUnproject() to get a line through your viewing volume and then check your vertex structure to see which is closest.