UPI YPTK - Padang
Overview of Graphics System
Eko Syamsuddin Hasrito, PhD
204481 Foundation of Computer Graphics
April 14, 2012
What is a graphics package?
software
that takes user input and passes it to applications that displays graphical output for applications
Application Model
Application Program
Graphics System
(2D/3D graphics, UI toolkit, input manager window system)
204481 Foundation of Computer Graphics
April 14, 2012
Application
Model (world):
the database & objects to be displayed may be geometry/attributes may be abstract data (e.g. fractal description) responsible for mapping the model to primitives supported by graphics package responsible for mapping user input to model changes
April 14, 2012 3
Program:
204481 Foundation of Computer Graphics
Graphics system components
Set of primitives Primitive attributes Graphics output Input handling Window management
204481 Foundation of Computer Graphics
April 14, 2012
2D Primitive possibilities
geometrical objects (point, line, circle, polygon, ...) mathematical curves text primitives fill patterns bitmapped images/textures
204481 Foundation of Computer Graphics
April 14, 2012
3D primitive possibilities
geometrical objects (line, polygon, polyhedron, sphere, ) mathematical surfaces light sources camera/eye points hierarchy placeholders object boundaries
204481 Foundation of Computer Graphics
April 14, 2012
Primitive attributes
color thickness position orientation transparency behavior
204481 Foundation of Computer Graphics
April 14, 2012
Graphics output
scan-conversion: used to map graphics commands (sets of primitives/attributes) to pixel values to be placed in frame buffer rendering of objects into screen space providing a view of the application model
204481 Foundation of Computer Graphics
April 14, 2012
Input handling
receive input from physical devices map this input to logical devices for applications apps register interest in events or devices event-driven programming
render_from_database(); while(1){ wait for input switch(input){ case 1: call_routine1(); case 2: call_routine2(); } render_from_database(); }
204481 Foundation of Computer Graphics
April 14, 2012
Window management
manage screen space mediate between application programs provide logical output canvases each app. believes it has an entire screen with its own coordinate system
204481 Foundation of Computer Graphics
April 14, 2012
10
Goals of graphics packages
Abstraction; Device-independence
logical input devices logical output devices (!) provide abstraction from hardware for app. produce application portability
Appropriate primitive/attribute types
204481 Foundation of Computer Graphics
April 14, 2012
11
OpenGL
mid-level, device-independent, portable graphics subroutine package developed primarily by SGI 2D/3D graphics, lower-level primitives (polygons) does not include low-level I/O management basis for higher-level libraries/toolkits
204481 Foundation of Computer Graphics
April 14, 2012
12
Basic User Interface Concepts
Pradondet Nilagupta
204481 Foundation of Computer Graphics
April 14, 2012
13
Outline of input devices
A short outline of input devices and the implementation of a graphical user interface is given:
Physical input devices used in graphics Virtual devices Polling is compared to event processing UI toolkits are introduced by generalizing event processing
204481 Foundation of Computer Graphics
April 14, 2012
14
Physical Devices
Actual, physical input devices include:
Dials (Potentiometers) Selectors Pushbuttons Switches Keyboards (collections of pushbuttons called \keys") Trackballs (relative motion) Mice (relative motion) Joysticks (relative motion, direction) Tablets (absolute position) Etc.
April 14, 2012 15
204481 Foundation of Computer Graphics
Virtual Devices
Devices can be classified according to the kind of value they return:
Button: Return a Boolean value; can be depressed or released. Key: Return a "character"; that is, one of a given set of code values. String: Return a sequence of characters. Selector: Return an integral value (in a given range). Choice: Return an option (menu, callback, ...) Valuator: Return a real value (in a given range). Locator: Return a position in (2D/3D) space (eg. several ganged valuators). Stroke: Return a sequence of positions. Pick: Return a scene component.
April 14, 2012 16
204481 Foundation of Computer Graphics
Device Association
To obtain device independence:
Design an application in terms of virtual (abstract) devices. Implement virtual devices using physical devices e.g. Valuator Mouse-X >
There are certain natural associations:
But if the naturally associated device does not exist on a platform,
one can make do with other possibilities: e.g. Valuator number entered on keyboard >
"public interface / private implementation"
204481 Foundation of Computer Graphics
April 14, 2012
17
Device Input Modes (1/2)
Return values from devices may be provided in: Request Mode: Alternating application and device
execution application requests a return and then suspends execution; device wakes up, provides input and then suspends execution; application resumes execution. Sample Mode: Concurrent application and device execution device continually updates register(s) or memory location(s); application may read at any time.
204481 Foundation of Computer Graphics
April 14, 2012 18
Device Input Modes (2/2)
Event Mode: Concurrent application and device execution together with a concurrent queue management service
device continually offers input to the queue application may request selections and services from the queue (or the queue may interrupt the ap plication).
204481 Foundation of Computer Graphics
April 14, 2012
19
Application Structure
With respect to device input modes,applications may be structured to engage in
requesting polling or sampling event processing
Events may or may not be interruptive. If not interruptive, they may be read in a
blocking non-blocking
fashion.
204481 Foundation of Computer Graphics
April 14, 2012 20
Polling and Sampling
In polling,
Value of input device constantly checked in a tight loop Wait for a change in status
Generally, polling is inecient and should be avoided, particularly in time-sharing systems. In sampling, value of an input device is read and then the program proceeds.
No tight loop Typically used to track sequence of actions (the mouse)
April 14, 2012 21
204481 Foundation of Computer Graphics
Event Queues (1/3)
Upon change in status of device, this process places a record into an event queue. Application can request read-out of queue:
Number of events 1st waiting event Highest priority event 1st event of some category All events Specify which events should be placed in queue Clear and reset the queue Etc.
April 14, 2012 22
Application can also
204481 Foundation of Computer Graphics
Event Queues (2/3)
Queue reading may be blocking or nonblocking Processing may be through callbacks Events may be processed interruptively Events can be associated with more than devices Events can be restricted to particular areas of the screen, based on the cursor position.
April 14, 2012 23
204481 Foundation of Computer Graphics
Event Queues (3/3)
Events can be very general or specific:
A mouse button or keyboard key is depressed. A mouse button or keyboard key is released. The cursor enters a window. The cursor has moved more than a certain amount. An Expose event is triggered under X when a window becomes visible. A Configure event is triggered when a window is resized. A timer event may occur after a certain interval.
April 14, 2012 24
204481 Foundation of Computer Graphics
Toolkits and Callbacks
Event-loop processing can be generalized:
Instead of switch, use table lookup. Each table entry associates an event with a callback function. When event occurs, corresponding callback is invoked. Provide an API to make and delete table entries. Divide screen into parcels, and assign different callbacks to different parcels (X Windows does thi s). Event manager does most or all of the administration.
April 14, 2012 25
204481 Foundation of Computer Graphics
Widgets (1/2)
Modular UI functionality is provided through a set of widgets: Widgets are parcels of the screen that can respond to events. A widget has a graphical representation that suggests its function. Widgets may respond to events with a change in appearance, as well as issuing callbacks.
204481 Foundation of Computer Graphics
April 14, 2012
26
Widgets (2/2)
Widgets are arranged in a parent/child hierarchy.
Event-process definition for parent may apply to child, and child may add additional event-process definitions Event-process definition for parent may be redefined within child
Widgets may have multiple parts, and in fact may be composed of other
widgets in a heirarchy.
Some UI toolkits: Xm, Xt, SUIT, FORMS, Tk : : :
204481 Foundation of Computer Graphics
April 14, 2012 27
Source :
Pradondet Nilagupta Dept. of Computer Engineering Kasetsart University
204481 Foundation of Computer Graphics
April 14, 2012 28