PDA

View Full Version : How to pick or drag a 2D polygon in OpenGL by mouse??



siuchick
02-17-2002, 10:29 PM
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?!

http://www.opengl.org/discussion_boards/ubb/frown.gif

nexusone
02-18-2002, 05:11 AM
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:
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?!

http://www.opengl.org/discussion_boards/ubb/frown.gif