SlideShare a Scribd company logo
1 of 22
Input and Interaction
1
Objectives
• Introduce the basic input devices
• Physical Devices
• Logical Devices
• Input Modes
• Event-driven input
• Introduce double buffering for smooth animations
• Programming event input with GLUT
2
Project Sketchpad
• Ivan Sutherland (MIT 1963) established the basic interactive
paradigm that characterizes interactive computer graphics:
• User sees an object on the display
• User points to (picks) the object with an input device (light pen, mouse,
trackball)
• Object changes (moves, rotates, morphs)
• Repeat
3
Graphical Input
• Devices can be described either by
• Physical properties
• Mouse
• Keyboard
• Trackball
• Logical Properties
• What is returned to program via API
• A position
• An object identifier
• Modes
• How and when input is obtained
• Request or event
4
Physical Devices
5
mouse trackball
light pen
data tablet joy stick space ball
Incremental (Relative) Devices
• Devices such as the data tablet return a position directly to the
operating system
• Devices such as the mouse, trackball, and joy stick return
incremental inputs (or velocities) to the operating system
• Must integrate these inputs to obtain an absolute position
• Rotation of cylinders in mouse
• Roll of trackball
• Difficult to obtain absolute position
• Can get variable sensitivity
6
Logical Devices
• Consider the C and C++ code
• C++: cin >> x;
• C: scanf (“%d”, &x);
• What is the input device?
• Can’t tell from the code
• Could be keyboard, file, output from another program
• The code provides logical input
• A number (an int) is returned to the program regardless of the physical
device
7
Graphical Logical Devices
•Graphical input is more varied than input to standard
programs which is usually numbers, characters, or
bits
•Two older APIs (GKS, PHIGS) defined six types of
logical input
• Locator: return a position
• Pick: return ID of an object
• Keyboard: return strings of characters
• Stroke: return array of positions
• Valuator: return floating point number
• Choice: return one of n items
8
X Window Input
•The X Window System introduced a client-server model
for a network of workstations
• Client: OpenGL program
• Graphics Server: bitmap display with a pointing device and a keyboard
9
Input Modes
• Input devices contain a trigger which can be used to send a signal to
the operating system
• Button on mouse
• Pressing or releasing a key
• When triggered, input devices return information (their measure) to
the system
• Mouse returns position information
• Keyboard returns ASCII code
10
Request Mode
• Input provided to program only when user triggers the device
• Typical of keyboard input
• Can erase (backspace), edit, correct until enter (return) key (the trigger) is
depressed
11
Event Mode
• Most systems have more than one input device, each of which can
be triggered at an arbitrary time by a user
• Each trigger generates an event whose measure is put in an event
queue which can be examined by the user program
12
Event Types
• Window: resize, expose, iconify
• Mouse: click one or more buttons
• Motion: move mouse
• Keyboard: press or release a key
• Idle: nonevent
• Define what should be done if no other event is in queue
13
Callbacks
• Programming interface for event-driven input
• Define a callback function for each type of event the graphics system
recognizes
• This user-supplied function is executed when the event occurs
• GLUT example: glutMouseFunc(mymouse)
14
mouse callback function
GLUT callbacks
GLUT recognizes a subset of the events recognized by any particular
window system (Windows, X, Macintosh)
• glutDisplayFunc
• glutMouseFunc
• glutReshapeFunc
• glutKeyboardFunc
• glutIdleFunc
• glutMotionFunc, glutPassiveMotionFunc
15
GLUT Event Loop
•Recall that the last line in main.c for a program
using GLUT must be
glutMainLoop();
which puts the program in an infinite event loop
•In each pass through the event loop, GLUT
• looks at the events in the queue
• for each event in the queue, GLUT executes the appropriate
callback function if one is defined
• if no callback is defined for the event, the event is ignored
16
The display callback
•The display callback is executed whenever GLUT
determines that the window should be refreshed, for
example
• When the window is first opened
• When the window is reshaped
• When a window is exposed
• When the user program decides it wants to change the display
•In main.c
• glutDisplayFunc(mydisplay) identifies the function
to be executed
• Every GLUT program must have a display callback
17
Posting redisplays
•Many events may invoke the display callback function
• Can lead to multiple executions of the display callback on a
single pass through the event loop
•We can avoid this problem by instead using
glutPostRedisplay();
which sets a flag.
•GLUT checks to see if the flag is set at the end of the
event loop
•If set then the display callback function is executed
18
Animating a Display
•When we redraw the display through the display
callback, we usually start by clearing the window
• glClear()
then draw the altered display
•Problem: the drawing of information in the frame
buffer is decoupled from the display of its contents
• Graphics systems use dual ported memory
•Hence we can see partially drawn display
• See the program single_double.c for an example with a
rotating cube
19
Double Buffering
•Instead of one color buffer, we use two
• Front Buffer: one that is displayed but not written to
• Back Buffer: one that is written to but not displayed
•Program then requests a double buffer in main.c
• glutInitDisplayMode(GL_RGB | GL_DOUBLE)
• At the end of the display callback buffers are swapped
20
void mydisplay()
{
glClear(GL_COLOR_BUFFER_BIT|….)
.
/* draw graphics here */
.
glutSwapBuffers()
}
Using the idle callback
• The idle callback is executed whenever there are no events in
the event queue
• glutIdleFunc(myidle)
• Useful for animations
21
void myidle() {
/* change something */
t += dt
glutPostRedisplay();
}
Void mydisplay() {
glClear();
/* draw something that depends on t */
glutSwapBuffers();
}
Using globals
•The form of all GLUT callbacks is fixed
• void mydisplay()
• void mymouse(GLint button, GLint state,
GLint x, GLint y)
•Must use globals to pass information to callbacks
22
float t; /*global */
void mydisplay()
{
/* draw something that depends on t
}

More Related Content

What's hot

Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4PrathimaBaliga
 
Graphics software
Graphics softwareGraphics software
Graphics softwareMohd Arif
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive SachiniGunawardana
 
Devices that output Hardcopy
Devices that output HardcopyDevices that output Hardcopy
Devices that output HardcopyMaryam Fida
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewingRabin BK
 
Graph coloring and_applications
Graph coloring and_applicationsGraph coloring and_applications
Graph coloring and_applicationsmohammad alkhalil
 
Polygon filling
Polygon fillingPolygon filling
Polygon fillingAnkit Garg
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODSSanthiNivas
 
Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)shalinikarunakaran1
 
I/O devices - Computer graphics
I/O devices -  Computer graphicsI/O devices -  Computer graphics
I/O devices - Computer graphicsAmritha Davis
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphicsSHIVANI SONI
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxHome
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - ShadingMichael Heron
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSnehrurevathy
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit NotesAAKANKSHA JAIN
 
Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)RohitK71
 

What's hot (20)

Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4
 
Graphics software
Graphics softwareGraphics software
Graphics software
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive
 
Video display devices
Video display devicesVideo display devices
Video display devices
 
Devices that output Hardcopy
Devices that output HardcopyDevices that output Hardcopy
Devices that output Hardcopy
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewing
 
Graph coloring and_applications
Graph coloring and_applicationsGraph coloring and_applications
Graph coloring and_applications
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODS
 
Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)Attributes of output primitive(line attributes)
Attributes of output primitive(line attributes)
 
Shading
ShadingShading
Shading
 
I/O devices - Computer graphics
I/O devices -  Computer graphicsI/O devices -  Computer graphics
I/O devices - Computer graphics
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptx
 
GRPHICS06 - Shading
GRPHICS06 - ShadingGRPHICS06 - Shading
GRPHICS06 - Shading
 
COLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICSCOLOR CRT MONITORS IN COMPUTER GRAPHICS
COLOR CRT MONITORS IN COMPUTER GRAPHICS
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)Computer graphics curves and surfaces (1)
Computer graphics curves and surfaces (1)
 

Similar to Input and Interaction: Devices, Modes, and Event-Driven Programming

Computer Graphics with OpenGL presentation Slides.pptx
Computer Graphics with OpenGL presentation Slides.pptxComputer Graphics with OpenGL presentation Slides.pptx
Computer Graphics with OpenGL presentation Slides.pptxAnandM62785
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.Girish Ghate
 
Hill ch2ed3
Hill ch2ed3Hill ch2ed3
Hill ch2ed3Kunal Verma
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDLWingston
 
Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL Sharath Raj
 
07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptxKushalSrivastava23
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUJohn Colvin
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2NokiaAppForum
 
Lecture 6 introduction to open gl and glut
Lecture 6   introduction to open gl and glutLecture 6   introduction to open gl and glut
Lecture 6 introduction to open gl and glutsimpleok
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGLSyed Zaid Irshad
 
cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppttadudemise
 
ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.
ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.
ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.PunyaGowda8
 
3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptxssuser255bf1
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programmingMohammed Romi
 
Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...bhargavi804095
 
Better Interactive Programs
Better Interactive ProgramsBetter Interactive Programs
Better Interactive ProgramsSyed Zaid Irshad
 

Similar to Input and Interaction: Devices, Modes, and Event-Driven Programming (20)

Computer Graphics with OpenGL presentation Slides.pptx
Computer Graphics with OpenGL presentation Slides.pptxComputer Graphics with OpenGL presentation Slides.pptx
Computer Graphics with OpenGL presentation Slides.pptx
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
Hill ch2ed3
Hill ch2ed3Hill ch2ed3
Hill ch2ed3
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
Open gl
Open glOpen gl
Open gl
 
2D graphics
2D graphics2D graphics
2D graphics
 
Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL Computer Graphics Project Report on Sinking Ship using OpenGL
Computer Graphics Project Report on Sinking Ship using OpenGL
 
07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPU
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
 
Lecture 6 introduction to open gl and glut
Lecture 6   introduction to open gl and glutLecture 6   introduction to open gl and glut
Lecture 6 introduction to open gl and glut
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
03_GUI.ppt
03_GUI.ppt03_GUI.ppt
03_GUI.ppt
 
cse581_03_EventProgramming.ppt
cse581_03_EventProgramming.pptcse581_03_EventProgramming.ppt
cse581_03_EventProgramming.ppt
 
ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.
ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.
ppt_3DWM_CG-1[1] 04july.ppt of wind mill project.
 
3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx3 CG_U1_P2_PPT_3 OpenGL.pptx
3 CG_U1_P2_PPT_3 OpenGL.pptx
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
 
Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...Python is a high-level, general-purpose programming language. Its design phil...
Python is a high-level, general-purpose programming language. Its design phil...
 
Better Interactive Programs
Better Interactive ProgramsBetter Interactive Programs
Better Interactive Programs
 
2.5 gui
2.5 gui2.5 gui
2.5 gui
 

More from Syed Zaid Irshad

Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdfSyed Zaid Irshad
 
DBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_SolutionDBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_SolutionSyed Zaid Irshad
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptxSyed Zaid Irshad
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
Professional Issues in Computing
Professional Issues in ComputingProfessional Issues in Computing
Professional Issues in ComputingSyed Zaid Irshad
 
Reduce course notes class xi
Reduce course notes class xiReduce course notes class xi
Reduce course notes class xiSyed Zaid Irshad
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xiiSyed Zaid Irshad
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to DatabaseSyed Zaid Irshad
 
Computer Programming
Computer ProgrammingComputer Programming
Computer ProgrammingSyed Zaid Irshad
 
ICS 2nd Year Book Introduction
ICS 2nd Year Book IntroductionICS 2nd Year Book Introduction
ICS 2nd Year Book IntroductionSyed Zaid Irshad
 
Security, Copyright and the Law
Security, Copyright and the LawSecurity, Copyright and the Law
Security, Copyright and the LawSyed Zaid Irshad
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer ArchitectureSyed Zaid Irshad
 
Information Networks
Information NetworksInformation Networks
Information NetworksSyed Zaid Irshad
 
Basic Concept of Information Technology
Basic Concept of Information TechnologyBasic Concept of Information Technology
Basic Concept of Information TechnologySyed Zaid Irshad
 
Introduction to ICS 1st Year Book
Introduction to ICS 1st Year BookIntroduction to ICS 1st Year Book
Introduction to ICS 1st Year BookSyed Zaid Irshad
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operatorsSyed Zaid Irshad
 

More from Syed Zaid Irshad (20)

Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdf
 
DBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_SolutionDBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_Solution
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Professional Issues in Computing
Professional Issues in ComputingProfessional Issues in Computing
Professional Issues in Computing
 
Reduce course notes class xi
Reduce course notes class xiReduce course notes class xi
Reduce course notes class xi
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to Database
 
C Language
C LanguageC Language
C Language
 
Flowchart
FlowchartFlowchart
Flowchart
 
Algorithm Pseudo
Algorithm PseudoAlgorithm Pseudo
Algorithm Pseudo
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
ICS 2nd Year Book Introduction
ICS 2nd Year Book IntroductionICS 2nd Year Book Introduction
ICS 2nd Year Book Introduction
 
Security, Copyright and the Law
Security, Copyright and the LawSecurity, Copyright and the Law
Security, Copyright and the Law
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Data Communication
Data CommunicationData Communication
Data Communication
 
Information Networks
Information NetworksInformation Networks
Information Networks
 
Basic Concept of Information Technology
Basic Concept of Information TechnologyBasic Concept of Information Technology
Basic Concept of Information Technology
 
Introduction to ICS 1st Year Book
Introduction to ICS 1st Year BookIntroduction to ICS 1st Year Book
Introduction to ICS 1st Year Book
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 

Recently uploaded

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Recently uploaded (20)

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Input and Interaction: Devices, Modes, and Event-Driven Programming

  • 2. Objectives • Introduce the basic input devices • Physical Devices • Logical Devices • Input Modes • Event-driven input • Introduce double buffering for smooth animations • Programming event input with GLUT 2
  • 3. Project Sketchpad • Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics: • User sees an object on the display • User points to (picks) the object with an input device (light pen, mouse, trackball) • Object changes (moves, rotates, morphs) • Repeat 3
  • 4. Graphical Input • Devices can be described either by • Physical properties • Mouse • Keyboard • Trackball • Logical Properties • What is returned to program via API • A position • An object identifier • Modes • How and when input is obtained • Request or event 4
  • 5. Physical Devices 5 mouse trackball light pen data tablet joy stick space ball
  • 6. Incremental (Relative) Devices • Devices such as the data tablet return a position directly to the operating system • Devices such as the mouse, trackball, and joy stick return incremental inputs (or velocities) to the operating system • Must integrate these inputs to obtain an absolute position • Rotation of cylinders in mouse • Roll of trackball • Difficult to obtain absolute position • Can get variable sensitivity 6
  • 7. Logical Devices • Consider the C and C++ code • C++: cin >> x; • C: scanf (“%d”, &x); • What is the input device? • Can’t tell from the code • Could be keyboard, file, output from another program • The code provides logical input • A number (an int) is returned to the program regardless of the physical device 7
  • 8. Graphical Logical Devices •Graphical input is more varied than input to standard programs which is usually numbers, characters, or bits •Two older APIs (GKS, PHIGS) defined six types of logical input • Locator: return a position • Pick: return ID of an object • Keyboard: return strings of characters • Stroke: return array of positions • Valuator: return floating point number • Choice: return one of n items 8
  • 9. X Window Input •The X Window System introduced a client-server model for a network of workstations • Client: OpenGL program • Graphics Server: bitmap display with a pointing device and a keyboard 9
  • 10. Input Modes • Input devices contain a trigger which can be used to send a signal to the operating system • Button on mouse • Pressing or releasing a key • When triggered, input devices return information (their measure) to the system • Mouse returns position information • Keyboard returns ASCII code 10
  • 11. Request Mode • Input provided to program only when user triggers the device • Typical of keyboard input • Can erase (backspace), edit, correct until enter (return) key (the trigger) is depressed 11
  • 12. Event Mode • Most systems have more than one input device, each of which can be triggered at an arbitrary time by a user • Each trigger generates an event whose measure is put in an event queue which can be examined by the user program 12
  • 13. Event Types • Window: resize, expose, iconify • Mouse: click one or more buttons • Motion: move mouse • Keyboard: press or release a key • Idle: nonevent • Define what should be done if no other event is in queue 13
  • 14. Callbacks • Programming interface for event-driven input • Define a callback function for each type of event the graphics system recognizes • This user-supplied function is executed when the event occurs • GLUT example: glutMouseFunc(mymouse) 14 mouse callback function
  • 15. GLUT callbacks GLUT recognizes a subset of the events recognized by any particular window system (Windows, X, Macintosh) • glutDisplayFunc • glutMouseFunc • glutReshapeFunc • glutKeyboardFunc • glutIdleFunc • glutMotionFunc, glutPassiveMotionFunc 15
  • 16. GLUT Event Loop •Recall that the last line in main.c for a program using GLUT must be glutMainLoop(); which puts the program in an infinite event loop •In each pass through the event loop, GLUT • looks at the events in the queue • for each event in the queue, GLUT executes the appropriate callback function if one is defined • if no callback is defined for the event, the event is ignored 16
  • 17. The display callback •The display callback is executed whenever GLUT determines that the window should be refreshed, for example • When the window is first opened • When the window is reshaped • When a window is exposed • When the user program decides it wants to change the display •In main.c • glutDisplayFunc(mydisplay) identifies the function to be executed • Every GLUT program must have a display callback 17
  • 18. Posting redisplays •Many events may invoke the display callback function • Can lead to multiple executions of the display callback on a single pass through the event loop •We can avoid this problem by instead using glutPostRedisplay(); which sets a flag. •GLUT checks to see if the flag is set at the end of the event loop •If set then the display callback function is executed 18
  • 19. Animating a Display •When we redraw the display through the display callback, we usually start by clearing the window • glClear() then draw the altered display •Problem: the drawing of information in the frame buffer is decoupled from the display of its contents • Graphics systems use dual ported memory •Hence we can see partially drawn display • See the program single_double.c for an example with a rotating cube 19
  • 20. Double Buffering •Instead of one color buffer, we use two • Front Buffer: one that is displayed but not written to • Back Buffer: one that is written to but not displayed •Program then requests a double buffer in main.c • glutInitDisplayMode(GL_RGB | GL_DOUBLE) • At the end of the display callback buffers are swapped 20 void mydisplay() { glClear(GL_COLOR_BUFFER_BIT|….) . /* draw graphics here */ . glutSwapBuffers() }
  • 21. Using the idle callback • The idle callback is executed whenever there are no events in the event queue • glutIdleFunc(myidle) • Useful for animations 21 void myidle() { /* change something */ t += dt glutPostRedisplay(); } Void mydisplay() { glClear(); /* draw something that depends on t */ glutSwapBuffers(); }
  • 22. Using globals •The form of all GLUT callbacks is fixed • void mydisplay() • void mymouse(GLint button, GLint state, GLint x, GLint y) •Must use globals to pass information to callbacks 22 float t; /*global */ void mydisplay() { /* draw something that depends on t }