How to drag object in opengl by mouse?

The position and direction of the object is changed at anytime.I want to drag the object by my mouse.

How to do this in opengl?

I’m sorry for so many question?this is the last
Thanks everybody here.

dragging involves selection. So search on this forum for “picking”.

For draging, I think you could first transform a point on the object to window space


then feed this into…
gluUnProject(mouse.x, mouse.y, object.z, …);

to get back that point, and find the new translation for the object.

Dragging in ortho projection can be simpler though.

C’mon, this has nothing to do with Advanced OpenGL. This is a UI question, and possibly a question on whatever scene graph library you’re using.