How to drag the line segment by selecting the vert

I am fairly new to Opengl. I have a question related to picking and dragging. I searched some posts here but cannot find related answers. My problem is as follows.

The line_loop (2D) is created by opengl. I need to pick a vertex of the line segment and then drag it to somewhere in the 2D screen.

If I pick up the vertex of the line, the buffer can be created from glSelectBuffer. The problem is that how I can know which vertex is selected from the returned buffer? The buffer stores the name of the vertex. But it seems the vertex does not has a name in GL_RENDER mode.

Thank you in advance!

Wouldn’t it be easier to simply check the vertex positions against the mouse position or whatever pointing device you use for picking and dragging in your code? (I suppose you have access to the vertex data of your line loop)

Thanks,

How can I convert the coordinates x and y in the screen to the 3D scene in openGL since I need the coordinates in 3D to redraw the model?

If using selection mode, how can I remain the changes in the selection mode?

Hi,

You can use the gluUnProject() func for to make the conversion.

This is a link that explain how to use it
http://nehe.gamedev.net/article/using_gluunproject/16013/