Events and Coordinates Lecture 5 Fri, Sep 5, 2003.

Slides:



Advertisements
Similar presentations
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Advertisements

Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
CS 450: COMPUTER GRAPHICS GLUT INPUT FUNCTIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 3 Additional Drawing Tools Ureerat Suksawatchon Department of Computer.
Chapter 3: Input and Interaction Instructor: Shih-Shinh Huang 1.
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
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.
CSC461 Lecture 9: GLUT Callbacks Objectives Introduce double buffering for smooth animations Programming event input with GLUT.
Write a Simple Program with OpenGL & GLUT. Books and Web Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible.
CS 480/680 Computer Graphics Programming with Open GL Part 8: Working with Callbacks Dr. Frederick C Harris, Jr. Fall 2011.
Guide to Programming with Python
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Chapter 3 Working with Symbols and Interactivity.
1 Grade Chapter  To know Parts of the computer, follow these steps as shown below:
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.
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.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 3.
1. Chapter 12 Inserting Shapes and WordArt 3 Inserting Shapes, WordArt, and More Create shapes, text boxes, and WordArt to add visual appeal to a Word.
Lecture 3 OpenGL.
Glut Coordinate System Used in keyboard and mouse callbacks x y w h [window]
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
® Microsoft Office 2010 Excel Tutorial 1: Getting Started with Excel.
Write a Simple Program with OpenGL & GLUT. Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible
Blender 2.5 Interface. The Blender Interface Penggunaan Mouse.
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
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.
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
Computer Graphics I, Fall 2010 Working with Callbacks.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Processing TYWu. Where can I download? 2.0b9 Windows 32-bit.
Presented By: Weidong WU, Ph.D. Date: Part I Creating a drawing format for the paper size A (11 x 8.5) 1. Start Pro/E wildfire. 2. File  set.
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
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
In this activity, we are going to type a simple Chinese sentence with Microsoft Word by Tsang-jei Input Method and Simplified Tsang-jei Input Method. 1Start.
Punch! Pro Platinum Home Design Adding Windows. Click on the Floor Tab, and then click on the Window icon. Your cursor will now have a little window attached.
Chap 3 Viewing and Transformation
Project 2 Function Plotter Mon, Sep 22, 2003 Due Mon, Sep 29, 2003.
Midterm: Question 1 (35%) (30 minutes) Write an assembly program to draw a rectangle. – (5%) Show a message to ask for information of the rectangle – (5%)
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Variables. Something to mention… void setup(){ size(200, 200); background(255); smooth(); } void draw() { stroke(0); strokeWeight(abs(mouseX-pmouseX));
INTRODUCTION TO OPENGL
Basic Program with OpenGL and GLUT
COMP261 Lecture 4 Graphs 3 of 3.
Review GLUT Callback Functions
More Events.
Working with Callbacks
Keyboard Input.
Introduction to the Mouse
Milestone 2 Overview.
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
The User Interface Lecture 2 Mon, Aug 27, 2007.
Working with Callbacks
Coordinate Systems and Transforming the Coordinates
Graphing Calculator Lesson 1: Graphing Lines and Finding Intercepts
2D Graphics Lecture 4 Fri, Aug 31, 2007.
The View Frustum Lecture 10 Fri, Sep 14, 2007.
Basic Input and Output CSE 120 Winter 2019
Lecture #5 Interactive Input Methods
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Presentation transcript:

Events and Coordinates Lecture 5 Fri, Sep 5, 2003

Mouse and Keyboard Interaction Through the callback functions, we may process mouse clicks and keystrokes. This will be our only form of input to our programs.

Processing Mouse Clicks The mouse function has prototype void mouse(int button, int state, int x, int y); Values of button GLUT_BUTTON_LEFT GLUT_BUTTON_RIGHT Values of state GLUT_UP GLUT_DOWN

Processing Mouse Clicks x and y are the x and y screen coordinates of the mouse when the key was pressed, measured in pixels. y is measured from the top of the window down. x is measured from the left of the window across.

Processing Mouse Clicks Skeleton code for mouse(). void mouse(int button, int state, int x, int y) { // Filter out other mouse events if (button == GLUT_BUTTON_LEFT && state == GLUT_DOWN) { // Do something } glutPostRedisplay(); }

Processing Keystrokes The keyboard function has prototype void keyboard(unsigned char key, int x, int y); key is any ASCII character on the keyboard. x and y are the x and y screen coordinates of the mouse when the key was pressed.

Processing Keystrokes Skeleton code for keyboard(). void keyboard(unsigned char key, int x, int y) { // Switch on designated keys only switch (key) { case ‘a’: // Do something default: break; } glutPostRedisplay(); }

Processing Special Keystrokes The special function has prototype void special(int key, int x, int y); key is nearly any non-ASCII character on the keyboard. Values of key GLUT_KEY_LEFT – left arrow key, etc. GLUT_KEY_F1 – F1 function key, etc. GLUT_KEY_HOME – home key, etc.

Processing Special Keystrokes x and y are the x and y screen coordinates of the mouse when the key was pressed.

Processing Special Keystrokes Skeleton code for special(). void special(int key, int x, int y) { // Switch on designated keys only switch (key) { case GLUT_KEY_LEFT: // Do something default: break; } glutPostRedisplay(); }

Example: Drawing an Octagon DrawOctagon.cpp

Chapter 3 More Drawing Tools

World Coordinates The world coordinate system is the coordinate system of the model itself, expressed in world units. It is established by calling gluOrtho2D(). gluOrtho2D(xmin, xmax, ymin, ymax).

Screen Coordinates The screen (or window) coordinate system is the coordinate system of the screen (or window), expressed in pixels. It is established by calling glViewport(). glViewport(left, bottom, width, height).

Changing Coordinate Systems We might need to convert from one coordinate system to another When we go from screen coordinates (e.g., a mouse click) to world coordinates. When we resize the window.

Changing Coordinate Systems ab d c (X, Y) rs u v (x, y) Screen coordinates World coordinates

Change of Coordinates The points (X, Y) and (x, y) occupy the same relative positions in their respective rectangles. Therefore, (x – r)/(s – r) = (X – a)/(b – a) and so x = X(s – r)/(b – a) + (br – as)/(b – a). Similarly for y.

Example: Change of Coordinates Given the statements express x and y in terms of X and Y. x = X/40 – 8, y = Y/40 – 6. gluOrtho2D(-8, 8, -6, 6); glViewport(0, 0, 640, 480);

Change of Coordinates Furthermore, since the mouse() function measures the y-coordinate from the top down, we must make an additional adjustment. Normally we will replace y by screenHeight – y. In the last example, we now have x = X/40 – 8, y = (screenHeight – Y)/40 – 6.

Change of Coordinates If we want to convert world coordinates into screen coordinates, this will require the inverse transformation. In the last example, we find X = 40x + 320, Y = screenHeight – (40y + 240).