CS 450: COMPUTER GRAPHICS GLUT INPUT FUNCTIONS SPRING 2015 DR. MICHAEL J. REALE.

Slides:



Advertisements
Similar presentations
Intro to Computers!.
Advertisements

Microsoft Office 2007-Illustrated Introductory, Windows Vista Edition Windows XP Unit A.
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
DESCRIBING INPUT DEVICES
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 3: Introduction.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 GLUT Callback Functions.
Based on slides created by Edward Angel
CSC461 Lecture 9: GLUT Callbacks Objectives Introduce double buffering for smooth animations Programming event input with GLUT.
Learning About Technology Chapter 2. 2 Learning New Tools How do you learn to use new tools?  Read the instruction manual Programming a VCR Cooling my.
CS 480/680 Computer Graphics Programming with Open GL Part 8: Working with Callbacks Dr. Frederick C Harris, Jr. Fall 2011.
Customizing Your Toolbars in Microsoft Office Lunch and Learn: June 7, 2005.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
Events and Coordinates Lecture 5 Fri, Sep 5, 2003.
Microsoft Office Outlook 2013 Microsoft Office Outlook 2013 Courseware # 3252 Lesson 3: Working with People.
1 Working with Callbacks Yuanfeng Zhou Shandong University.
More on Drawing in OpenGL: Examples CSC 2141 Introduction to Computer Graphics.
WORKING WITH CALLBACKS Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive.
Interaction with Graphics System
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
CS 450: COMPUTER GRAPHICS REVIEW: GLUT INPUT FUNCTIONS SPRING 2015 DR. MICHAEL J. REALE.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Lecture 3 OpenGL.
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
Computer Graphics I, Fall 2010 Input and Interaction.
CS 450: COMPUTER GRAPHICS PORTRAIT OF AN OPENGL PROGRAM SPRING 2015 DR. MICHAEL J. REALE.
1. Chapter 4 Customizing Paragraphs 3 More Paragraph Changes Highlight a paragraph in Word by applying borders and shading. Sort paragraphs to control.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
Adobe Flash CS3 Revealed Chapter 3 - WORKING WITH SYMBOLS AND INTERACTIVITY.
Exploring Windows and Essential Computing Concepts 1 Windows Desktop u Windows Basics u Icon u Start Button u My Computer u Network Neighborhood u Recycle.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
Mouse Events & Keyboard Inputs Flash ActionScript Introduction to Thomas Lövgren
Microsoft Office XP Illustrated Introductory, Enhanced Started with Windows 2000 Getting.
Lesson No: 6 Introduction to Windows XP CHBT-01 Basic Micro process & Computer Operation.
1 Washington WASHINGTON UNIVERSITY IN ST LOUIS Jyoti Parwatikar January 7, MSR Tutorial Monitoring WUGS Switch Jyoti Parwatikar January 7, 2002.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
An Inspiration Software Tutorial INDEX Changing a Symbol in Inspiration Adding a Symbol in Inspiration Moving a Symbol in inspiration Adding text under.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
Computer Graphics I, Fall 2010 Working with Callbacks.
University of New Mexico
Pop-Up Menus Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 26, 2003.
Mouse events, Advanced camera control George Georgiev Telerik Corporation
7th Meeting TYPE and CLICK. Keyboard Keyboard, as a medium of interaction between user and machine. Is a board consisting of the keys to type a sentence.
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
Windows 95/NT/XP. What is Windows 95/NT/XP n A program that sets up an environment for you to work in on your computer, based on colorful pictures (icons)
12/22/ :38 1 Comp 175C - Computer Graphics Dan Hebert Computer Graphics Comp 175 Chapter 3 Instructor: Dan Hebert.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Input and Interaction Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Menus Pull-downs and popups. Tooltips –a ToolTip is a context-sensitive text string that is displayed in a popup window when the mouse rests over a particular.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Digital Literacy Introduction to Computers Unit 1, Lesson 1.
INTRODUCTION TO OPENGL
Review GLUT Callback Functions
Working with Callbacks
Introduction to the Mouse
Data Representation ASCII.
The User Interface Lecture 2 Mon, Aug 27, 2007.
Event Driven Programming
Advanced Menuing, Introduction to Picking
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Working with Callbacks
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Lecture #5 Interactive Input Methods
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Presentation transcript:

CS 450: COMPUTER GRAPHICS GLUT INPUT FUNCTIONS SPRING 2015 DR. MICHAEL J. REALE

INTRODUCTION Apart from creating the window, GLUT also allows accessing the mouse and keyboard as well as creating popup menus.

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 BUTTONS glutMouseFunc(mouseFunction); void mouseFunction(GLint button, GLint action, GLint xMouse, GLint yMouse) Called when a mouse button is FIRST PRESSED or RELEASED Mouse click = two events (a press and release) GLint button  can be GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON GLint action  either GLUT_DOWN or GLUT_UP GLint xMouse, yMouse  mouse coordinates at time of event

MOUSE MOVING If the MOUSE is MOVING and ANY MOUSE BUTTON is DOWN: glutMotionFunc(mouseMovingButton); void mouseMovingButton(GLint xMouse, GLint yMouse) If the MOUSE is MOVING and NO MOUSE BUTTONS are DOWN: glutPassiveMotionFunc(mouseMovingNoButton); void mouseMovingNoButton(GLint xMouse, GLint yMouse) Usually means you have to keep track of what mouse buttons are down with your glutMouseFunc() callback E.g., have a global called “leftMouseDown” and set it in mouseFunction()

KEYBOARD: REGULAR KEYS glutKeyboardFunc(keyboard) void keyboard(GLubyte key, GLint xMouse, GLint yMouse) Function called when the user PRESSES a key. NOTE: It will CONTINUE to be called if the user keeps holding the key down! GLubyte key = character value or ASCII code for key pressed GLint xMouse, yMouse = mouse coordinates at time of key press

KEYBOARD: SPECIAL KEYS glutSpecialFunc(specialKeyboard) Void specialKeyboard(GLint specialKey, GLint xMouse, GLint yMouse) Uses for special-purpose keys like the function keys (F1, F2, etc.) and arrow keys GLint specialKey = integer-valued GLUT symbolic constant Examples: GLUT_KEY_F1, GLUT_KEY_UP, GLUT_KEY_HOME, etc. GLint xMouse, yMouse = mouse coordinates at time of key press

POPUP MENUS GLUT also allows you to create popup menus and submenus These are generally set up in the same place where you register the GLUT callback functions However, you can also add/remove items in other parts of your code

CREATING, SETTING, AND DESTROY A MENU 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 glutSetMenu(menuID) Sets menu as current menu for display window glutDestroyMenu(menuID) Destroys menu If menu happens to be the current menu for the display window  window now has no menu assigned

GETTING CURRENT MENU ID currentMenuID = glutGetMenu() Returns current menu attached to display window (or 0 if no menu is attached)

ADDING MENU ENTRIES glutAddMenuEntry(charString, menuItemNumber) Add a menu item to current menu (determined by either last call to glutCreateMenu() or by glutSetMenu()) charString = text for menu entry menuItemNumber = menu item number NOTE: Order you add them in determines order of display ALSO NOTE: ID does NOT have to follow order of display (e.g., first item could have an ID of 500) FURTHER NOTE: Two or more items can have the SAME ID

ATTACHING A MOUSE BUTTON We also need to determine which mouse button will be used to open the menu: glutAttachMenu(button) button = can be GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON

CREATING SUBMENUS Just create another menu: GLuint submenuID = glutCreateMenu(subMenuFunction); glutAddMenuEntry(“First submenu item”, 1); … Then, add menu to main menu: glutCreateMenu(menuFunction); … glutAddSubMenu(“Submenu Option”, submenuID);

CHANGING THE MENU MOUSE BUTTON To change the mouse button used to open menus, first detach it: glutDetachMenu(mouseButton); Then attach the button you want

DELETING MENU ITEMS glutRemoveMenuItem(itemNumber) Removes itemNumber from the current menu If multiple items have the same number, will delete one of them