1 / 14

OpenGL & GLUT Mouse Interaction & Camera Control

OpenGL & GLUT Mouse Interaction & Camera Control. Mouse events, Advanced camera control. George Georgiev. Telerik Corporation. www.telerik.com. Table of Contents. GLUT Mouse Interaction Mouse up/down events Passive motion Active motion OpenGL Camera Default transformation

jania
Download Presentation

OpenGL & GLUT Mouse Interaction & Camera Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGL & GLUTMouse Interaction & Camera Control Mouse events, Advanced camera control George Georgiev Telerik Corporation www.telerik.com

  2. Table of Contents • GLUT Mouse Interaction • Mouse up/down events • Passive motion • Active motion • OpenGL Camera • Default transformation • “Manual” control • Custom camera class

  3. GLUT Mouse Interaction Mouse event callbacks

  4. GLUT Mouse Interaction • GLUT provides mouse detection capabilities • Advantages • Multi-platform • Similar to other GLUT routines • Easy to code • Disadvantages • Doesn’t receive device information • No scroll information • Unstable ‘leave’ and ‘enter’ events

  5. GLUT Mouse Interaction • Detecting mouse buttons • Registering callback function • glutMouseFunc(void(*func)(int button, int state, int x, int y)) • func –mouse button callback function • button – mouse button raising the event • state – type of event • x, y – cursor coordinates (from upper left corner)

  6. GLUT Mouse Interaction • Detecting mouse buttons (2) • Callback parameter values • button • GLUT_LEFT_BUTTON • GLUT_MIDDLE_BUTTON • GLUT_RIGHT_BUTTON • state • GLUT_DOWN • GLUT_UP

  7. GLUT Mouse Interaction • Detecting mouse buttons (2) • Callback parameter values • button • GLUT_LEFT_BUTTON • GLUT_MIDDLE_BUTTON • GLUT_RIGHT_BUTTON • state • GLUT_DOWN • GLUT_UP

  8. GLUT Mouse Interaction • Detecting movement • Types • Passive • Mouse moves • No buttons pressed • Active • Mouse moves • One or more buttons pressed

  9. GLUT Mouse Interaction • Passive motion • Registering callback function • glutPassiveMotionFunc(void(*func)(int x, int y)) • func – mouse passive motion callback • x, y – cursor coordinates (from upper left corner)

  10. GLUT Mouse Interaction • Active motion • Registering callback function • glutMotionFunc(void(*func)(int x, int y)) • func – mouse active motion callback • x, y – cursor coordinates (from upper left corner)

  11. GLUT Mouse Interaction • GLUT Mouse leave and entry routines • Detect when cursor leaves and enters window • Registering callback • glutEntryFunc(void(*func)(int state)) • Func – callback handling cursor leaving and entering window • State – enter or leave event • GLUT_ENTERED • GLUT_LEFT

  12. GLUT Mouse Interaction • Cursor-related routines • glutWarpPointer (int x, int y) • Sends cursor to specified coordinates • glutSetCursor (int cursor) • Sets the cursor image (style) for the window • Values: • GLUT_CURSOR_NONE, GLUT_CURSOR_INFO, GLUT_CURSOR_DESTROY, etc… • Google for more (much, much more)

  13. Mouse Interaction • Object-oriented mouse handling • Custom mouse class • Current cursor position • Last cursor position and/or drag-begin position • Current mouse button states • Last mouse button states • Cursor style • Anything else you can think of

  14. Custom mouse class Live Demo

More Related