Upload
kory-barrett
View
219
Download
2
Embed Size (px)
Citation preview
CS 450: COMPUTER GRAPHICS
REVIEW: GLUT INPUT FUNCTIONS
SPRING 2015
DR. MICHAEL J. REALE
MOUSE COORDINATES: UP IS DOWN
• All mouse coordinates in GLUT are in SCREEN COORDINATES with Y INVERTED (so up is down)
• Relative to TOP-LEFT window corner!
• If storing, do something like this:
• currentYMouse = windowHeight – yMouse;
MOUSE
• glutMouseFunc();
• Mouse button is FIRST PRESSED or RELEASED
• Mouse click = two events (a press and release)
• glutMotionFunc();
• Mouse MOVING and ANY mouse button is down
• glutPassiveMotionFunc();
• Mouse MOVING and NO mouse buttons are down
KEYBOARD
• glutKeyboardFunc()
• Regular keys (ASCII code)
• When the user PRESSES a key continues calling as long as key is down
• glutSpecialFunc(specialKeyboard)
• Special keys (F1, arrow keys, etc.) uses GLUT constants
POPUP MENUS
• GLuint menuID = glutCreateMenu(menuFunction)
• void menuFunction(GLint menuItemNumber)
• Called when a menu item is clicked on
• GLint menuItemNumber = index of menu item
• In function, decide what to do for each menu item
• glutAddMenuEntry(charString, menuItemNumber)
• Add menu item string with item number
• glutAttachMenu(button)
• Determine which mouse button opens menu
• glutAddSubMenu(submenu)
• Add another menu as submenu of current menu