Title: 310482: Graphics Programming
1310482 Graphics Programming
- Seree Chinodom
- seree_at_buu.ac.th
- http//www.compsci.buu.ac.th/seree/lecture/310482
2Display Technologies
- Cathode Ray Tubes (CRTs)
- Most common display device today
- Evacuated glass bottle
- Extremely high voltage
- Heating element (filament)
- Electrons pulled towards anode focusing cylinder
- Vertical and horizontal deflection plates
- Beam strikes phosphor coating on front of tube
3Electron Gun
- Contains a filament that, when heated, emits a
stream of electrons - Electrons are focused with an electromagnet into
a sharp beam and directed to a specific point of
the face of the picture tube - The front surface of the picture tube is coated
with small phospher dots - When the beam hits a phospher dot it glows with a
brightness proportional to the strength of the
beam and how often it is excited by the beam
4Display Technologies CRTs
- Vector Displays
- Early computer displays basically an
oscilloscope - Control X,Y with vertical/horizontal plate
voltage - Often used intensity as Z
- Name two disadvantages
- Just does wireframe
- Complex scenes ? visible flicker
5Display Technologies CRTs
- Raster Displays
- Raster A rectangular array of points or dots
- Pixel One dot or picture element of the raster
- Scan line A row of pixels
6Display Technologies CRTs
- Raster Displays
- Black and white television an oscilloscope with
a fixed scan pattern left to right, top to
bottom - To paint the screen, computer needs to
synchronize with the scanning pattern of raster - Solution special memory to buffer image with
scan-out synchronous to the raster. We call this
the framebuffer.
7Display Technologies CRTs
- Phosphers
- Flourescence Light emitted while the phospher is
being struck by electrons - Phospherescence Light emitted once the electron
beam is removed - Persistence The time from the removal of the
excitation to the moment when phospherescence has
decayed to 10 of the initial light output
8Display Technologies CRTs
- Raster Displays
- Frame must be refreshed to draw new images
- As new pixels are struck by electron beam, others
are decaying - Electron beam must hit all pixels frequently to
eliminate flicker - Critical fusion frequency
- Typically 60 times/sec
- Varies with intensity, individuals, phospher
persistence, lighting...
9Display Technologies CRTs
- Raster Displays
- Interlaced Scanning
- Assume can only scan 30 times / second
- To reduce flicker, divide frame into two fields
of odd and even lines
1/30 Sec
1/30 Sec
1/60 Sec
1/60 Sec
1/60 Sec
1/60 Sec
Field 1
Field 2
Field 2
Field 1
Frame
Frame
10Display Technologies CRTs
- Raster Displays
- Scanning (left to right, top to bottom)
- Vertical Sync Pulse Signals the start of the
next field - Vertical Retrace Time needed to get from the
bottom of the current field to the top of the
next field - Horizontal Sync Pulse Signals the start of the
new scan line - Horizontal Retrace The time needed to get from
the end of the current scan line to the start of
the next scan line
11Display Technology Color CRTs
- Color CRTs are much more complicated
- Requires manufacturing very precise geometry
- Uses a pattern of color phosphors on the screen
- Why red, green, and blue phosphors?
Delta electron gun arrangement
In-line electron gun arrangement
12Display Technology Color CRTs
- Color CRTs have
- Three electron guns
- A metal shadow mask to differentiate the beams
13Display Technology Raster
- Raster CRT pros
- Allows solids, not just wireframes
- Leverages low-cost CRT technology (i.e., TVs)
- Bright! Display emits light
- Cons
- Requires screen-size memory array
- Discreet sampling (pixels)
- Practical limit on size (call it 40 inches)
- Bulky
- Finicky (convergence, warp, etc)
14Display Technology LCDs
- Liquid Crystal Displays (LCDs)
- LCDs organic molecules, naturally in crystalline
state, that liquefy when excited by heat or E
field - Crystalline state twists polarized light 90º
15Display Technology LCDs
- Transmissive reflective LCDs
- LCDs act as light valves, not light emitters, and
thus rely on an external light source. - Laptop screen backlit, transmissive display
- Palm Pilot/Game Boy reflective display
16Display Technology Plasma
- Plasma display panels
- Similar in principle to fluorescent light tubes
- Small gas-filled capsules are excited by
electric field,emits UV light - UV excites phosphor
- Phosphor relaxes, emits some other color
17Display Technology
- Plasma Display Panel Pros
- Large viewing angle
- Good for large-format displays
- Fairly bright
- Cons
- Expensive
- Large pixels (1 mm versus 0.2 mm)
- Phosphors gradually deplete
- Less bright than CRTs, using more power
18Display Technology DMDs
- Digital Micromirror Devices (projectors)
- Microelectromechanical (MEM) devices, fabricated
with VLSI techniques
19Display Technology DMDs
- DMDs are truly digital pixels
- Vary grey levels by modulating pulse length
- Color multiple chips, or color-wheel
- Great resolution
- Very bright
- Flicker problems
20Display Technologies Organic LED Arrays
- Organic Light-Emitting Diode (OLED) Arrays
- The display of the future? Many think so.
- OLEDs function like regular semiconductor LEDs
- But with thin-film polymer construction
- Thin-film deposition or vacuum deposition
processnot grown like a crystal, no
high-temperature doping - Thus, easier to create large-area OLED sheet
21Display Technologies Organic LED Arrays
- OLED pros
- Transparent
- Flexible
- Light-emitting, and quite bright (daylight
visible) - Large viewing angle
- Fast (lt 1 microsecond off-on-off)
- Can be made large or small
- OLED cons
- Not quite there yet (96x64 displays)
- Not very robust, display lifetime a key issue
22Raster Scan Displays
- Beam of electrons deflected onto a phosphor
coated screen - Phosphors emit light when excited by the
electrons - Phosphor brightness decays -- need to refresh
the display - Phosphors make up screen elements called pixels
23Basic Definitions
- Raster A rectangular array of points or dots.
- Pixel (Pel) One dot or picture element of the
raster - Scan line A row of pixels
Video raster devices display an image by
sequentially drawing out the pixels of the scan
lines that form the raster.
24Frame Buffers
- A frame buffer may be thought of as computer
memory organized as a two-dimensional array with
each (x,y) addressable location corresponding to
one pixel. - Bit Planes or Bit Depth is the number of bits
corresponding to each pixel. - A typical frame buffer resolution might be
- 640 x 480 x 8
- 1280 x 1024 x 8
- 1280 x 1024 x 24
251-Bit Memory, Monochrome Display (Bitmap Display)
263-Bit Color Display
27True Color Display
- 24 bitplanes, 8 bits per color gun.
- 224 16,777,216
8
8
Red
8
Blue
28Color Map Look-Up Tables
- Extends the number of colors that can be
displayed by a given number of bit-planes.
RED
y
max
GREEN
255
BLUE
y
Pixel displayed
7
1001
1010
0001
at x', y'
6
100110100001
67
B
R
G
Pixel in
bit map
0
at x', y'
0
x
x
0
max
Frame buffer
Look-up table
Display
29Pseudo color
28 x 24 Color Map LUT
30Drawing
- Most computer generated images made up of
geometric primitives (polygons, lines, points) - Application draws them by setting bits in the
- framebuffer
- Most graphics applications involve scene
database management
Graphic Application
Device Driver
Scene Database
Framebuffer
Display
31A DDA Line Drawing Function
- Line(int x1, int y1, int x2, int y2)
-
- int dx x1 - x2, dy y2 -y1
- int n max(abs(dx),abs(dy))
- float dt n, dxdt dx/dt, dydt dy/dt
- float x x1, y y1
- while (n--)
-
- DrawPoint( round(x), round(y) )
- x dxdt
- y dydt
-
32We Can Do Better Than That...
- Get rid of all those nasty floating point
operations - The idea find the next pixel from the current
one - So which of the green pixels is next?
33The Key
- Were only ever going to go right one pixel, or
up and right one pixel (if the slope of the line
is between 0 and 1). Call these two choices E
and NE - Lets think of pixels as lattice points on a
grid - Given an X coordinate, we only need to choose
between y and y1 (y is the Y coordinate of the
last pixel)
34The Midpoint Test
- Look at the vertical grid line that our line
intersects - On which side of the midpoint (y1/2) does the
intersection lie? - If its above the midpoint, go NE, otherwise go E
35Our Example
36Implicit Functions
- Normally, a line is defined as y mx b
- Instead, define ,F(x,y) ax by c and let the
line be everywhere where F(x,y) 0 - Now, if F(x,y) gt 0 , were above the line, and
if F(x,y) lt 0 , were below the line
37Who Cares?
- We can evaluate the implicit line function at the
- midpoint to figure out where to draw next!
- In fact, we can use the last function evaluation
to find the next one cheaply! - For ANY x, y
- F(x 1,y) - F(x,y) a
- F(x 1,y 1) - F(x,y) a - b
38Midpoint Algorithm
- Line(int x1, int y1, int x2, int y2)
-
- int dx x2 - x1, dy y2 -y1
- int e 2dy - dx
- int incrE 2dy, incrNE 2(dy-dx)
- int x x1, y y1
- DrawPoint( x, y )
- while (x lt x2)
-
- x
- if ( e lt 0 ) e incrE
- else y e incrNE
- DrawPoint( x, y )
-
- e holds the implicit function evaluation at
each x value (actually, its multiplied by 2,
but all we care about is the sign). - Easy extension for lines with arbitrary slopes