PDA

View Full Version : showing menu mouseclick event with opengl object



validator
8th March 2008, 22:53
Hi, I draw objects such as dog and cat with opengl. When I click mouse right button in a location ,if there is a cat in this loation a menu opens and shows cat' s properties , if there is a a dog in this location a menu opens and shows dog' s properties .How can I do this .Please help

wysota
8th March 2008, 23:25
In general you need to be able to tell what items collide with a line starting in the camera position and crossing the projection plane at the coordinates pointed by the mouse event. You'll need to do some math or better yet search on OpenGL (or 3D in general) sites for appropriate formulas. Then it's just a matter of creating a QMenu object and using QMenu::exec() to trigger the menu. And it'll be better if you use QWidget::contextMenuEvent() instead of QWidget::mouseReleaseEvent() or similar.