Keyboard Mouse and Menus



Similar documents
The mouse callback. Positioning. Working with Callbacks. Obtaining the window size. Objectives

Input and Interaction. CS 432 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Computer Graphics (Basic OpenGL, Input and Interaction)

Graphics Pipeline in a Nutshell

Input and Interaction. Project Sketchpad. Graphical Input. Physical Devices. Objectives

CMSC 427 Computer Graphics 1

Input and Interaction

Lecture 3: Coordinate Systems and Transformations

Computer Graphics Labs

Chapter 1 Introduction to OpenGL

CMSC 427 Computer Graphics 1

An Introduction to. Graphics Programming

Computer Graphics Labs

OpenGL & Delphi. Max Kleiner. 1/22

Methodology for Lecture. Review of Last Demo

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Windows Basics. Developed by: D. Cook

Canterbury Maps Quick Start - Drawing and Printing Tools

Einführung Computergraphik (WS 2014/15)

How To Understand How To Use A Computer On A Macintosh (Apple) Computer With A Mouse And Mouse (Apple Macintosh)

Enter your User Id and Password and click the Log In button to launch the application.

SERVICE CENTER ONLINE ENTRY

Computer Basics: Tackling the mouse, keyboard, and using Windows

CRM Connector Installation & Integration USER GUIDE

Windows 8.1 Tips and Tricks

4BA6 - Topic 4 Dr. Steven Collins. Chap. 5 3D Viewing and Projections

Introduction to Computers: Session 3 Files, Folders and Windows

3D-GIS in the Cloud USER MANUAL. August, 2014

Transformations in the pipeline

The very basic basics of PowerPoint XP

Creating Database Tables in Microsoft SQL Server

Inking in MS Office 2013

COURSE DESCRIPTION. Queries in Microsoft Access. This course is designed for users with a to create queries in Microsoft Access.

As you look at an imac you will notice that there are no buttons on the front of the machine as shown in figure 1.

Getting Started Guide. Chapter 14 Customizing LibreOffice

Chapter 9 Slide Shows

LMS USER GUIDE WELCOME KIT

Module 1. 4 Login-Send Message to Teacher

Using the Remote Desktop Connection for Mac

CMSC 425 Game Programming 1

Digital Signatures. To learn more about digital signatures view this White Paper by Adobe.

Fountas & Pinnell Online Data Management System. Manage. Main Navigation Manage Districts/Schools/Classes Manage Groups Manage Students Manage Account

Auto Clicker Tutorial

Layout Tutorial. Getting Started

Get-Snap. Once you have installed the DataCAD 9.03 update, you are ready to take advantage of this new feature.

CLOUD DIGITISER 2014!

A Short Tutorial on Using Visio 2010 for Entity-Relationship Diagrams

Implementação. Interfaces Pessoa Máquina 2010/ Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

FOR PREPARING THE CALL REPORT EXCEL DATA FILE AND ELECTRONIC SUBMISSION OF THE CRS AND E-DATA

CE 490 Transportation Engineering Network Analysis

Macintosh System OSX #1

Managing Your Desktop with Exposé, Spaces, and Other Tools

Interaction: Mouse and Keyboard DECO1012

Terminal 4 Content Types. Need help? Call the ITD Lab, x7471

Chapter 9. Editing Features. Learning Objectives

The SMART Board Interactive Whiteboard

Quick Start Guide to Logging in to Online Banking

How to set up a database in Microsoft Access

SketchUp Instructions

Popup Menu User Reference (English) 12 May 2005 Version: 4.0

Web Ambassador Quick Start

Introduction to MS WINDOWS XP

Shipment Label Header Guide

Crown Field Support Engineering

NDA ISSUE 1 STOCK # CallCenterWorX-Enterprise IMX MAT Quick Reference Guide MAY, NEC America, Inc.

Quick Help Guide SAP CRMS Login, Navigation and Layout

Ingham County Equalization/Tax Mapping Viewer Tutorial

CREATE A 3D MOVIE IN DIRECTOR

Understand the Sketcher workbench of CATIA V5.

DocuSign Desk Guide. Sign a Contract Electronically Other Actions in DocuSign 2. Assign Signature to Authorized Signer.

USER GUIDE Appointment Manager

Browsing and working with your files and folder is easy with Windows 7 s new look Windows Explorer.

Adobe Captivate Tips for Success

Within minutes you can transform your high-resolution digital image in to a DVquality movie that pans, zooms and rotates the once-still image.

INFORMATION SERVICES TECHNOLOGY GUIDE RHS STUDENT EMPLOYMENT WEB APPLICATION

Computer Basics Handouts: Computer Basics

Keyboard Shortcuts Instead of the Mouse NOTES

KaleidaGraph Quick Start Guide

Xpressions Web Assistant

Microsoft Office Access 2007 Basics

The Simple Steps For On-Line Enrollment

LOCAL FLEET TRACKING. GPS Fleet Tracking Help Guide

Help. Contents Back >>

Chapter 4. Backup / Restore

Learning Management System (LMS) User Guide Contents

Sweet Home 3D user's guide

AnzioWin FTP Dialog. AnzioWin version 15.0 and later

Instructions for using VPN and accessing your files remotely

Remote Desktop Services Guide

Practical Data Visualization and Virtual Reality. Virtual Reality VR Software and Programming. Karljohan Lundin Palmerius

User Tutorial on Changing Frame Size, Window Size, and Screen Resolution for The Original Version of The Cancer-Rates.Info/NJ Application

Scan-Line Fill. Scan-Line Algorithm. Sort by scan line Fill each span vertex order generated by vertex list

Your Assistant Collaboration Module

Microsoft PowerPoint 2008

Transcription:

Keyboard Mouse and Menus

Reshape Callback Whenever a window is initialized, moved or resized, the window sends an event to notify us of the change When we use GLUT, the event will be handled by the function registered by glutreshapefunc( ) This callback function should: Reestablish the rectangular-region that will be the new rendering-area Define the coordinate-system to which objects will be drawn

Reshape Callback Example: void reshape(int w, int h) { glviewport(0, 0, (GLlsizei) w, (GLlsizei) h); glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0.0, (GLsizei) w, 0.0, (GLsizei) h); } The coordinate system defined by w = 11 and h = 11: (11, 11) (0, 0)

Hidden Surface Removal OpenGL uses the depth-buffer method (also called Z-buffer) The method works by associating a depth for EACH pixel Z-buffer Algorithm: Depth values for all pixels are set to the largest possible value Draw objects in the scene in ANY order. Before each pixel is drawn, a comparison is done with the depth-value already stored at the pixel. The new pixel is drawn only if its z coordinate is smaller than the Z value in the buffer The Z-buffer is eventually updated with the distance of the new pixel Pseudocode: if (new_pixel_closer_than(prev_pixel_z) { draw_new_pixel( ); store_new_z(pixel_z); }

Example: Hidden Surface Removal glutinitdisplaymode(glut_depth.); glenable(gl_depth_test); : while (1) { glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); draw_3d_object_a( ); draw_3d_object_b( ); }

Keyboard Callbacks void glutkeyboardfunc(void (*f)(unsigned char key, int x, int y)) Registers the function f( ) that is called when a key is pressed; (x, y) is always measured from top left corner of the window void glutspecialfunc(void (*f)(int key, int x, int y)) Registers the callback that handles special keys (function, arrows, etc ) int glutgetmodifiers( ) Return one of GLUT_ACTIVE_SHIFT, GLUT_ACTIVE_CTRL or GLUT_ACTIVE_ALT if the key is pressed when a keyboard or mouse event are generated

Keyboard Callbacks Example: The callback registered by glutspecialfunc( ) will have tests like: if(key == GLUT_KEY_F1). // Function key F1 if(key == GLUT_KEY_F2). // Function key F2 The constants associated to the special keys are defined in glut.h

Keyboard Callbacks #define GLUT_KEY_F1 1 #define GLUT_KEY_F2 2 #define GLUT_KEY_F3 3 #define GLUT_KEY_F4 4 #define GLUT_KEY_F5 5 #define GLUT_KEY_F6 6 #define GLUT_KEY_F7 7 #define GLUT_KEY_F8 8 #define GLUT_KEY_F9 9 #define GLUT_KEY_F10 10 #define GLUT_KEY_F11 11 #define GLUT_KEY_F12 12 /* directional keys */ #define GLUT_KEY_LEFT 100 #define GLUT_KEY_UP 101 #define GLUT_KEY_RIGHT 102 #define GLUT_KEY_DOWN 103 #define GLUT_KEY_PAGE_UP 104 #define GLUT_KEY_PAGE_DOWN 105 #define GLUT_KEY_HOME 106 #define GLUT_KEY_END 107 #define GLUT_KEY_INSERT 108

Keyboard Callbacks Example: To have Control-c or Control-C terminate a program if ((glutgetmodifiers( ) == GLUT_ACTIVE_CTRL) && ((key == c ) (key == C ))) exit(0) NOTE: The modifiers also work with mouse functions

Mouse Callback void glutmousefunc(void (*f)(int button, int state, int x, int y)) Registers the mouse callback f( ) which handles the position (x, y) of the mouse in the window, its state (GLUT_UP or GLUT_DOWN) and the button causing the event (GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON GLUT_MIDDLE_BUTTON) EXAMPLE: void mymouse(int button, int state, int x, int y) { if(state == GLUT_DOWN && button == GLUT_LEFT_BUTTON) exit( ); }

Mouse Motion void glutmotionfunc(void (*f)(int x, int y)) void glutpassivemotionfunc(void (*f)(int x, int y)) Specify motion and passive motion (no button pressed) callback functions void glutentryfunc(void (*f)(int state)) State is GLUT_ENTERED or GLUT_LEFT depending on the mouse entering or leaving the window area

Menus int glutcreatemenu (void (*f)(int value)) Creates top level menu that uses callback f( ) which is passed an integer value from the menu entry. Returns a unique menu identifier void glutsetmenu (int id) Sets the current menu to id void glutaddmenuentry (char *name, int value) Adds entry to the current menu. Name is the entry name and value is returned to the menu callback

Menus int glutattachmenu (int button) Attaches current menu to the specified mouse button. Button is GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON or GLUT_MIDDLE_BUTTON void glutaddsubmenu (char *name, int menu) Adds a submenu entry name as the next entry in the current menu. The value of menu is the id of the submenu returned when the submenu was created

Menus Example: glutcreatemenu(mymenu); // single menu, no need for id glutaddmenuentry( Clear Screen, 1); glutaddmenuentry( Exit, 2); glutattachmenu(glut_right_button); Callback: void mymenu(int value) { if(value == 1) glclear( ); if(value == 2) exit(0); }