How to pick or drag a 2D polygon in OpenGL by mouse??

Dear all,

I am a newcomer in OpenGL and I’d like to ask how can I pick/ drag a 2D polygon?

I knew may be I can use glutMotionFunc() to call the moved mouse event…but, I have no idea on how to pick up an 2D object?!

There is a pick function in GL that you can use to tell which object is under the mouse pointer.
Try this example: http://nehe.gamedev.net/opengl7.asp lesson 33

As for a drag function, there is not drag and drop type function in GL.
You will have to write your own routin for that.
Just once you have picked the object with your mouse, just change the objects location to match the mouse movement until the button is released.

Originally posted by siuchick:
[b]Dear all,

I am a newcomer in OpenGL and I’d like to ask how can I pick/ drag a 2D polygon?

I knew may be I can use glutMotionFunc() to call the moved mouse event…but, I have no idea on how to pick up an 2D object?!

[/b]