hearn-50265;ISBN: 0-13-015390-7 book August 8,2003 14:44

CHAPTER 2 Overviewof GraphicsSystems

Awide,curved-screen,computer-graphicspresentation system and its control desk. (Courtesy of Silicon Graphics,Inc.and Trimension Systems. c 2003 SGI.All rights reserved.) [

34 hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 DisplayDevices 2-6 GraphicsNetworks 2-2 Raster-ScanSystems 2-7 Graphicson the Internet 2-3 GraphicsWorkstationsand Viewing 2-8 GraphicsSoftware Systems 2-9 Introduction toOpenGL 2-4 Input Devices 2-10 Summary 2-5 Hard-CopyDevices

he powerand utility of computergraphicsiswidelyrecognized,and abroadrange of graphicshardwareand softwaresystemsarenow available forapplicationsin virtuallyall fields.Graphicscapabilities T forbothtwo-dimensionaland three-dimensionalapplicationsare nowcommon,even on general-purposecomputers and handheld calculators.Withpersonalcomputers,wecanuseavariety of interactiveinput devicesand graphicssoftwarepackages.Forhigher-quality applications,wecan choosefrom anumberof sophisticated special-purposegraphicshardwaresys- temsand technologies.Inthischapter,weexplorethe basicfeaturesof graphics hardwarecomponents and graphicssoftwarepackages.

2-1 VIDEO DISPLAY DEVICES

Typically,the primary output deviceinagraphicssystem isavideo monitor (Fig. 2-1). The operation of most video monitors isbased on the standard cathode-raytube ( CRT )design,but severalothertechnologiesexist and solid- statemonitors mayeventuallypredominate.

FIGURE 2-1 Acomputer-graphicsworkstation. ( Courtesy of Silicon Graphics,Inc.,WhyNotFilms,and 525Post Production. c 2003 SGI.All rights reserved.) [ 35 hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

36 CHAPTER 2 Overviewof GraphicsSystems

RefreshCathode-RayTubes Figure2-2illustratesthe basicoperation of aCRT.Abeamofelectrons( cathode rays),emitted byanelectron gun,passesthrough focusing and deflection systems thatdirectthe beamtowardspecified positionson the phosphor-coated screen. The phosphorthen emits asmall spotof lightateachposition contacted bythe electron beam. Becausethe lightemitted bythe phosphorfadesvery rapidly, some method isneeded formaintaining the screen picture. One waytodothis istostorethe pictureinformation asacharge distribution within the CRT.This charge distribution canthen beused tokeep the phosphors activated. However, the most common method nowemployed formaintaining phosphorglowisto redrawthe picturerepeatedlybyquicklydirecting the electron beambackoverthe same screen points.Thistype of displayiscalled a refreshCRT, and the frequency atwhichapictureisredrawnonthe screen isreferred toasthe refreshrate. The primary components of anelectron guninaCRT arethe heated metal cathode and acontrol grid (Fig. 2-3). Heatissupplied tothe cathode bydirecting acurrentthrough acoil of wire,called the filament,inside the cylindricalcathode structure. Thiscauseselectronstobe“boiled off” the hotcathode surface. In the vacuuminside the CRTenvelope,the free,negativelycharged electronsare then accelerated towardthe phosphorcoating byahigh positivevoltage. The accelerating voltage canbegenerated withapositivelycharged metalcoating on the inside of the CRTenvelope nearthe phosphorscreen,oranaccelerating anode,asin Fig. 2-3,canbeused toprovide the positivevoltage. Sometimesthe electron gunisdesigned sothatthe accelerating anode and focusing system are within the same unit.

Magnetic Deflection Coils Phosphor- Focusing Coated System Screen Base

Electron Connector Electron Beam Pins Gun FIGURE 2-2 Basicdesign of amagnetic-deflection CRT.

Electron Focusing Beam Cathode Anode Path

Heating Filament

Control Accelerating FIGURE 2-3 Operation of Grid Anode anelectron gunwithan accelerating anode. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 Video DisplayDevices 37

Intensity of the electron beamiscontrolled bythe voltage atthe control grid, whichisametalcylinderthatfits overthe cathode. Ahigh negativevoltage ap- plied tothe control grid will shut offthe beambyrepelling electronsand stopping them from passing through the small hole atthe end of the control-grid structure. Asmallernegativevoltage on the control grid simplydecreasesthe numberof electronspassing through. Sincethe amountof lightemitted bythe phosphor coating dependson the numberof electronsstriking the screen,the brightness of adisplaypointiscontrolled byvarying the voltage on the control grid. This brightness,orintensity level,isspecified forindividualscreen positionswith graphicssoftwarecommands,asdiscussed in Chapter3. The focusing system in aCRT forcesthe electron beamtoconverge toasmall cross section asitstrikesthe phosphor.Otherwise,the electronswould repel each other,and the beamwould spreadout asitapproachesthe screen. Focusing is accomplished witheitherelectricormagneticfields.Withelectrostaticfocusing, the electron beamispassed through apositivelycharged metalcylindersothat electronsalong the centerline of the cylinderareinanequilibriumposition. This arrangementformsanelectrostaticlens,asshowninFig. 2-3,and the electron beamisfocused atthe centerof the screen in the same waythatanopticallens focusesabeamoflightataparticularfocaldistance. Similarlensfocusing effects canbeaccomplished withamagneticfield setupbyacoil mounted around the outside of the CRTenvelope,and magneticlensfocusing usuallyproducesthe smallest spotsizeonthe screen. Additionalfocusing hardwareisused in high-precision systemstokeep the beaminfocus atall screen positions.The distancethatthe electron beammust travel todifferentpoints on the screen variesbecausethe radius of curvaturefor most CRTsisgreaterthanthe distancefrom the focusing system tothe screen center.Therefore,the electron beamwill befocused properlyonlyatthe center of the screen. Asthe beammovestothe outeredgesof the screen,displayed imagesbecome blurred. Tocompensateforthis,the system canadjust the focusing according tothe screen position of the beam. Aswithfocusing,deflection of the electron beamcanbecontrolled witheither electricormagneticfields.Cathode-raytubesarenowcommonlyconstructed withmagnetic-deflection coilsmounted on the outside of the CRTenvelope,as illustrated in Fig. 2-2.Twopairs of coilsareused forthispurpose. One pairis mounted on the top and bottom of the CRTneck,and the otherpairismounted on oppositesidesof the neck. The magneticfield produced byeachpairof coils results in atransversedeflection forcethatisperpendiculartoboththe direction of the magneticfield and the direction of travel of the electron beam. Horizontal deflection isaccomplished withone pairof coils,and verticaldeflection withthe otherpair.The properdeflection amounts areattained byadjusting the current through the coils.When electrostaticdeflection isused,twopairs of parallel plates aremounted inside the CRTenvelope. One pairof platesismounted horizontally tocontrol verticaldeflection,and the otherpairismounted verticallytocontrol horizontaldeflection (Fig. 2-4). Spots of lightareproduced on the screen bythe transferof the CRTbeamen- ergytothe phosphor.When the electronsin the beamcollide withthe phosphor coating,theyarestopped and theirkineticenergyisabsorbed bythe phosphor. Part of the beamenergyisconverted byfriction intoheatenergy,and the remain- dercauseselectronsin the phosphoratomstomoveuptohigherquantum-energy levels.Afterashort time,the “excited” phosphorelectronsbegin dropping back totheirstable ground state,giving uptheirextraenergyassmall quantumsof lightenergycalled photons.Whatwesee on the screen isthe combined effectof all hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

38CHAPTER 2 Overviewof GraphicsSystems

Vertical Phosphor- Focusing Deflection Coated System Plates Screen Base

Electron Connector Electron Horizontal Beam FIGURE 2-4 Electrostatic Pins Gun Deflection deflection of the electron Plates beaminaCRT.

the electron lightemissions:aglowing spotthatquicklyfadesafterall the excited phosphorelectronshavereturned totheirground energylevel. The frequency(or color)ofthe lightemitted bythe phosphorisproportionaltothe energydifference between the excited quantumstateand the ground state. Differentkindsof phosphors areavailable foruseinCRTs.Besidescolor, amajordifferencebetween phosphors istheir persistence: howlong theycon- tinuetoemitlight(thatis,howlong beforeall excited electronshavereturned tothe ground state) afterthe CRTbeamisremoved. Persistenceisdefined as the time thatittakesthe emitted lightfrom the screen todecaytoone-tenthof its originalintensity.Lower-persistencephosphors requirehigherrefreshratesto maintain apictureonthe screen without flicker.Aphosphorwithlowpersistence canbeusefulforanimation,while high-persistencephosphors arebettersuited fordisplaying highlycomplex,staticpictures.Although some phosphors have persistencevaluesgreaterthan1second,general-purposegraphicsmonitors are usuallyconstructed withpersistenceinthe range from 10to60 microseconds. FIGURE 2-5 Intensity Figure2-5 shows the intensity distribution of aspoton the screen. The in- distribution of anilluminated tensity isgreatest atthe centerof the spot,and itdecreaseswithaGaussian phosphorspoton aCRT distribution out tothe edgesof the spot.Thisdistribution correspondstothe screen. cross-sectionalelectron density distribution of the CRTbeam. The maximumnumberof points thatcanbedisplayed without overlapona CRTisreferred toasthe resolution. Amoreprecisedefinition of resolution isthe numberof points percentimeterthatcanbeplotted horizontallyand vertically, although itisoften simplystated asthe totalnumberof points in eachdirection. Spotintensity hasaGaussiandistribution (Fig. 2-5),sotwoadjacentspots will appeardistinctaslong astheirseparation isgreaterthanthe diameteratwhich eachspothasanintensity of about 60 percentof thatatthe centerof the spot.This FIGURE 2-6 Two overlapposition isillustrated in Fig. 2-6.Spotsizealsodependson intensity.As illuminated phosphorspots moreelectronsareaccelerated towardthe phosphorpersecond,the diameters aredistinguishable when of the CRTbeamand the illuminated spotincrease. Inaddition,the increased theirseparation isgreater thanthe diameteratwhich excitation energytendstospreadtoneighboring phosphoratomsnotdirectlyin aspotintensity hasfallen to the pathofthe beam,whichfurtherincreasesthe spotdiameter.Thus,resolution 60 percentof maximum. of aCRT isdependenton the type of phosphor,the intensity tobedisplayed,and the focusing and deflection systems.Typicalresolution on high-quality systemsis 1280by1024,withhigherresolutionsavailable on manysystems.High-resolution systemsareoften referred toas high-definition systems .The physicalsizeofagraph- icsmonitor,on the otherhand,isgiven asthe lengthofthe screen diagonal,with sizesvarying from about 12inchesto27 inchesormore. ACRT monitorcanbe attached toavariety of computersystems,sothe numberof screen points that canactuallybeplotted alsodependson the capabilitiesof the system towhichit isattached. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 Video DisplayDevices 39

Raster-ScanDisplays The most common type of graphicsmonitoremploying aCRT isthe raster-scan display, based on technology.Inaraster-scansystem,the electron beam issweptacross the screen,one rowatatime,from top tobottom. Eachrowis referred toasa scanline. Asthe electron beammovesacross ascanline,the beamintensity isturned on and off(orsettosome intermediatevalue) tocreatea patternofilluminated spots.Picturedefinition isstored in amemory areacalled the refreshbuffer or frame buffer, wherethe term frame refers tothe totalscreen area.Thismemory areaholdsthe setof colorvaluesforthe screen points.These stored colorvaluesarethen retrieved from the refreshbufferand used tocontrol the intensity of the electron beamasitmovesfrom spottospotacross the screen. Inthisway,the pictureis“painted” on the screen one scanline atatime,as demonstrated in Fig. 2-7.Eachscreen spotthatcanbeilluminated bythe electron beamisreferred toasa pixel or pel (shortened formsof pictureelement ). Sincethe refreshbufferisused tostorethe setof screen colorvalues,itisalsosometimes called a colorbuffer. Also,otherkindsof pixel information,besidescolor,are stored in bufferlocations,soall the differentbufferareasaresometimesreferred tocollectivelyasthe “frame buffer”. The capability of araster-scansystem to storecolorinformation foreachscreen pointmakesitwell suited forthe realistic displayof scenescontaining subtle shading and colorpatterns.Home television sets and printers areexamplesof othersystemsusing raster-scanmethods. Rastersystemsarecommonlycharacterized bytheirresolution,whichisthe numberof pixel positionsthatcanbeplotted. Anotherproperty of video monitors is aspectratio, whichisnowoften defined asthe numberof pixel columnsdivided bythe numberof scanlinesthatcanbedisplayed bythe system. (Sometimesthe termaspectratio isused torefertothe numberof scanlinesdivided bythe number of pixel columns.) Aspectratio canalsobedescribed asthe numberof horizontal

(a) (b)

FIGURE 2-7 Araster-scan system displays anobjectasa setof discretepoints across (c)(d) eachscanline. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

40CHAPTER 2 Overviewof GraphicsSystems

points toverticalpoints (orviceversa)necessary toproduceequal-lengthlines in bothdirectionson the screen. Thus,anaspectratio of 4/3,forexample,means thatahorizontalline plotted withfour points hasthe same lengthasaverticalline plotted withthree points,whereline lengthismeasured in some physicalunits suchascentimeters.Similarly,the aspectratio of anyrectangle (including the total screen area)canbedefined tobethe widthofthe rectangle divided byits height. The range of colors orshadesof graythatcanbedisplayed on arastersystem dependson boththe typesof phosphorused in the CRTand the numberof bits perpixel available in the frame buffer.Forasimple black-and-whitesystem,each screen pointiseitheron oroff,soonlyone bitperpixel isneeded tocontrol the intensity of screen positions.Abitvalueof1,forexample,indicatesthatthe electron beamistobeturned on atthatposition,and avalueof0turnsthe beam off. Additionalbits allowthe intensity of the electron beamtobevaried over arange of valuesbetween “on” and “off”.Upto24bits perpixel areincluded in high-quality systems,whichcanrequireseveralmegabytesof storage forthe frame buffer,depending on the resolution of the system. Forexample,asystem with24bits perpixel and ascreen resolution of 1024by1024requires3megabytes of storage forthe refreshbuffer.The numberof bits perpixel in aframe bufferis sometimesreferred toaseitherthe depth of the bufferareaorthe numberof bit planes. Also,aframe bufferwithone bitperpixel iscommonlycalled a bitmap, and aframe bufferwithmultiple bits perpixel isa pixmap. But the termsbitmap and pixmaparealsoused todescribeotherrectangulararrays,whereabitmapis anypatternofbinary valuesand apixmapisamulticolorpattern. Aseachscreen refreshtakesplace,wetend tosee eachframe asasmooth continuation of the patternsin the previous frame,aslong asthe refreshrateis nottoo low.Belowabout 24framespersecond,wecanusuallyperceiveagap between successivescreen images,and the pictureappears toflicker.Old silent films,forexample,showthiseffectbecausetheywerephotographed atarateof 16framespersecond. When sound systemsweredeveloped in the 1920s,motion- picturefilm ratesincreased to24framespersecond,whichremoved flickering and the accompanying jerkymovements of the actors.Earlyraster-scancomputer systemsweredesigned witharefreshrateofabout 30 framespersecond. This producesreasonablygood results,but picturequality isimproved,uptoapoint, withhigherrefreshrateson avideo monitorbecausethe displaytechnologyon the monitorisbasicallydifferentfrom thatof film. Afilm projectorcanmaintain the continuous displayof afilm frame until the next frame isbroughtintoview.But on avideo monitor,aphosphorspotbeginstodecayassoon asitisilluminated. Therefore,currentraster-scandisplays performrefreshing atthe rateof60 to 80framespersecond,although some systemsnowhaverefreshratesof upto 120 framespersecond. And some graphicssystemshavebeen designed witha variable refreshrate. Forexample,ahigherrefreshratecould beselected fora stereoscopicapplication sothattwoviews of ascene (one from eacheyeposition) canbealternatelydisplayed without flicker.But othermethods,suchasmultiple frame buffers,aretypicallyused forsuchapplications. Sometimes,refreshratesaredescribed in units of cyclespersecond,orHertz (Hz),whereacycle correspondstoone frame. Using theseunits,wewould de- scribearefreshrateof60 framespersecond assimply60Hz.Atthe end of each scanline,the electron beamreturnstothe leftside of the screen tobegin display- ing the next scanline. The returntothe leftof the screen,afterrefreshing each scanline,iscalled the horizontalretrace of the electron beam. And atthe end of 1 1 eachframe (displayed in 80 to 60 of asecond),the electron beamreturnstothe top leftcornerof the screen ( verticalretrace )tobegin the next frame. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 Video DisplayDevices 41

0 1 2 3 FIGURE 2-8 Interlacing scanlineson araster-scandisplay.First,all points on the even-numbered (solid) scanlinesare displayed;then all points along the odd-numbered (dashed) linesare displayed.

Onsome raster-scansystemsand TV sets,eachframe isdisplayed in two passesusing an interlaced refreshprocedure. Inthe first pass,the beamsweeps across every otherscanline from top tobottom. Afterthe verticalretrace,the beamthen sweepsout the remaining scanlines(Fig. 2-8). Interlacing of the scan linesin thiswayallows us tosee the entirescreen displayed in one-half the time itwould havetaken tosweep across all the linesatoncefrom top tobottom. Thistechniqueisprimarilyused withslowerrefreshrates.Onanolder,30 frame- per-second,non-interlaced display,forinstance,some flickerisnoticeable. But 1 withinterlacing,eachofthe twopassescanbeaccomplished in 60 of asecond, whichbringsthe refreshratenearerto60 framespersecond. Thisisaneffective techniqueforavoiding flicker—provided thatadjacentscanlinescontain similar displayinformation.

Random-ScanDisplays When operated asa random-scandisplay unit,aCRT hasthe electron beam directed onlytothoseparts of the screen whereapictureistobedisplayed. Picturesaregenerated asline drawings,withthe electron beamtracing out the componentlinesone afterthe other.Forthisreason,random-scanmonitors are alsoreferred toas vectordisplays (or stroke-writing displays or calligraphic displays). The componentlinesof apicturecanbedrawnand refreshed bya random-scansystem in anyspecified order(Fig. 2-9). Apen plotteroperatesin a similarwayand isanexample of arandom-scan,hard-copydevice. Refreshrateonarandom-scansystem dependson the numberof linestobe displayed on thatsystem. Picturedefinition isnowstored asasetof line-drawing commandsin anareaof memory referred toasthe displaylist,refreshdisplayfile, vectorfile, or displayprogram. Todisplayaspecified picture,the system cycles through the setof commandsin the displayfile,drawing eachcomponentline in turn. Afterall line-drawing commandshavebeen processed,the system cycles backtothe first line command in the list.Random-scandisplays aredesigned to drawall the componentlinesof apicture30 to60 timeseachsecond,withupto 100,000 “short”linesin the displaylist.When asmall setof linesistobedisplayed, eachrefreshcycle isdelayed toavoid very high refreshrates,whichcould burn out the phosphor. Random-scansystemsweredesigned forline-drawing applications,suchas architecturaland engineering layouts,and theycannotdisplayrealisticshaded scenes.Sincepicturedefinition isstored asasetof line-drawing instructionsrather thanasasetof intensity valuesforall screen points,vectordisplays generallyhave higherresolutionsthanrastersystems.Also,vectordisplays producesmoothline drawingsbecausethe CRTbeamdirectlyfollows the line path. Arastersystem,by hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

42CHAPTER 2 Overviewof GraphicsSystems

(a)(b)

FIGURE 2-9 A random-scansystem draws the componentlinesof an objectin anyspecified order. (c)(d)

contrast,producesjagged linesthatareplotted asdiscretepointsets.However, the greaterflexibility and improved line-drawing capabilitiesof rastersystems haveresulted in the abandonmentof vectortechnology.

ColorCRT Monitors ACRT monitordisplays colorpicturesbyusing acombination of phosphors thatemitdifferent-colored light.The emitted lightfrom the differentphosphors mergestoformasingle perceived color,whichdependson the particularsetof phosphors thathavebeen excited. One waytodisplaycolorpicturesistocoatthe screen withlayers of different- colored phosphors.The emitted colordependson howfarthe electron beam penetratesintothe phosphorlayers.Thisapproach,called the beam-penetration method,typicallyused onlytwophosphorlayers:red and green. Abeamofslow electronsexcitesonlythe outerred layer,but abeamofvery fast electronspen- etratesthrough the red layerand excitesthe innergreen layer.Atintermediate beamspeeds,combinationsof red and green lightareemitted toshowtwoaddi- tionalcolors,orange and yellow.The speed of the electrons,and hencethe screen coloratanypoint,iscontrolled bythe beamacceleration voltage. Beampenetra- tion hasbeen aninexpensivewaytoproducecolor,but onlyalimited numberof colors arepossible,and picturequality isnotasgood aswithothermethods. Shadow-mask methodsarecommonlyused in raster-scansystems(includ- ing colorTV)sincetheyproduceamuchwiderrange of colors thanthe beam- penetration method. Thisapproachisbased on the waythatweseem toperceive colors ascombinationsof red,green,and bluecomponents,called the RGB color model. Thus,ashadow-maskCRTusesthree phosphorcolordots ateachpixel position. One phosphordotemits ared light,anotheremits agreen light,and the thirdemits abluelight.Thistype of CRThasthree electron guns,one foreach hearn-50265;ISBN: 0-13-015390-7 book July30,2003 15:15

2-1 Video DisplayDevices 43

Section Electron of Guns Shadow Mask

B

G

R

Magnified FIGURE 2-10 Operation Red Phosphor-Dot of adelta-delta, shadow-mask Triangle CRT.Three electron guns, Green Blue aligned withthe triangular color-dotpatternson the screen,aredirected toeach dottriangle byashadow Screen mask.

colordot,and ashadow-maskgrid just behind the phosphor-coated screen. The lightemitted from the three phosphors results in asmall spotof colorateachpixel position,sinceour eyestend tomerge the lightemitted from the three dots into one compositecolor.Figure2-10illustratesthe delta-delta shadow-maskmethod, commonlyused in colorCRTsystems.The three electron beamsaredeflected and focused asagroupontothe shadowmask,whichcontainsaseriesof holes aligned withthe phosphor-dotpatterns.When the three beamspass through a hole in the shadowmask,theyactivateadottriangle,whichappears asasmall colorspoton the screen. The phosphordots in the trianglesarearranged sothat eachelectron beamcanactivateonlyits corresponding colordotwhen itpasses through the shadowmask. Anotherconfiguration forthe three electron gunsis an in-line arrangementin whichthe three electron guns,and the corresponding red-green-bluecolordots on the screen,arealigned along one scanline insteadof in atriangularpattern. Thisin-line arrangementof electron gunsiseasiertokeep in alignmentand iscommonlyused in high-resolution colorCRTs. Weobtain colorvariationsin ashadow-maskCRTbyvarying the intensity levelsof the three electron beams.Byturning offtwoofthe three guns,weget onlythe colorcoming from the single activated phosphor(red,green,orblue). When all three dots areactivated withequalbeamintensities,wesee awhite color.Yellowisproduced withequalintensitiesfrom the green and red dots only, magentaisproduced withequalblueand red intensities,and cyanshows up when blueand green areactivated equally.Inaninexpensivesystem,eachofthe three electron beamsmightberestricted toeitheron oroff,limiting displays to eightcolors.Moresophisticated systemscanallowintermediateintensity levels tobesetforthe electron beams,sothatseveralmillion colors arepossible. Colorgraphicssystemscanbeused withseveraltypesof CRTdisplaydevices. Some inexpensivehome-computersystemsand video gameshavebeen designed forusewithacolorTV setand anRF (radio-frequency)modulator.The purposeof the RF modulatoristosimulatethe signalfrom abroadcast TV station. Thismeans thatthe colorand intensity information of the picturemust becombined and superimposed on the broadcast-frequencycarriersignalthatthe TV requiresas input.Then the circuitry in the TV takesthissignalfrom the RF modulator,extracts the pictureinformation,and paints iton the screen. Aswemightexpect,this hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

44 CHAPTER 2 Overviewof GraphicsSystems

extrahandling of the pictureinformation bythe RF modulatorand TV circuitry decreasesthe quality of displayed images. Compositemonitors areadaptationsof TV sets thatallowbypass of the broad- cast circuitry.Thesedisplaydevicesstill requirethatthe pictureinformation be combined,but no carriersignalisneeded. Sincepictureinformation iscombined intoacompositesignaland then separated bythe monitor,the resulting picture quality isstill notthe best attainable. ColorCRTsin graphicssystemsaredesigned as RGB monitors. Thesemoni- tors useshadow-maskmethodsand take the intensity level foreachelectron gun (red,green,and blue) directlyfrom the computersystem without anyinterme- diateprocessing. High-quality raster-graphicssystemshave24bits perpixel in the frame buffer,allowing 256voltage settingsforeachelectron gunand nearly 17million colorchoicesforeachpixel. AnRGB colorsystem with24bits of storage perpixel isgenerallyreferred toasa full-colorsystem ora true-colorsystem.

Flat-Panel Displays Although most graphicsmonitors arestill constructed withCRTs,othertech- nologiesareemerging thatmaysoon replaceCRTmonitors.The term flat-panel display refers toaclass of video devicesthathavereduced volume,weight,and powerrequirements compared toaCRT.Asignificantfeatureofflat-panel dis- plays isthattheyarethinnerthanCRTs,and wecanhang them on wallsorwear them on our wrists.Sincewecaneven writeonsome flat-panel displays,they arealsoavailable aspocketnotepads.Some additionalusesforflat-panel dis- plays areassmall TV monitors,calculatorscreens,pocketvideo-game screens, laptop computerscreens,armrest movie-viewing stationson airlines,advertise- mentboardsin elevators,and graphicsdisplays in applicationsrequiring rugged, portable monitors. Wecanseparateflat-panel displays intotwocategories: emissivedisplays and nonemissivedisplays. The emissivedisplays (or emitters)aredevicesthat convert electricalenergyintolight.Plasmapanels,thin-film electroluminescent displays,and light-emitting diodesareexamplesof emissivedisplays.FlatCRTs havealsobeen devised,in whichelectron beamsareaccelerated parallel tothe screen and then deflected 90 ◦ ontothe screen. But flatCRTshavenotproved tobeas successfulasotheremissivedevices.Nonemissivedisplays (or nonemitters)use opticaleffects toconvert sunlightorlightfrom some othersourceintographics patterns.The most importantexample of anonemissiveflat-panel displayisa liquid-crystaldevice. Plasmapanels, alsocalled gas-discharge displays, areconstructed byfilling the region between twoglass plateswithamixtureofgasesthatusuallyincludes neon. Aseriesof verticalconducting ribbonsisplaced on one glass panel,and a setof horizontalconducting ribbonsisbuiltintothe otherglass panel (Fig. 2-11). Firing voltagesapplied toanintersecting pairof horizontaland verticalconduc- tors causethe gasatthe intersection of the twoconductors tobreakdowninto aglowing plasmaof electronsand ions.Picturedefinition isstored in arefresh buffer,and the firing voltagesareapplied torefreshthe pixel positions(atthe in- tersectionsof the conductors)60 timespersecond. Alternating-currentmethods areused toprovide fasterapplication of the firing voltagesand,thus,brighter displays.Separation between pixelsisprovided bythe electricfield of the con- ductors.Figure2-12shows ahigh-definition plasmapanel. One disadvantage of plasmapanelshasbeen thattheywerestrictlymonochromaticdevices,but systemsarenowavailable withmulticolorcapabilities. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 Video DisplayDevices 45

Conductors

Gas

Glass Plate

Glass Plate

FIGURE 2-11 Basicdesign of aplasma-panel display FIGURE 2-12 Aplasma-panel display device. witharesolution of 2048 by2048 and ascreen diagonalof1.5 meters.(Courtesy of Photonics Systems. )

Conductors

Glass Plate

Glass Plate Phosphor

FIGURE 2-13 Basic design of athin-film electroluminescentdisplay device.

Thin-film electroluminescentdisplays aresimilarin construction toplasma panels.The differenceisthatthe region between the glass platesisfilled witha phosphor,suchaszincsulfide doped withmanganese,insteadofagas(Fig. 2-13). When asufficientlyhigh voltage isapplied toapairof crossing electrodes,the phosphorbecomesaconductorin the areaof the intersection of the twoelectrodes. Electricalenergyisabsorbed bythe manganeseatoms,whichthen releasethe energyasaspotof lightsimilartothe glowing plasmaeffectin aplasmapanel. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

46CHAPTER 2 Overviewof GraphicsSystems

Electroluminescentdisplays requiremorepowerthanplasmapanels,and good colordisplays arehardertoachieve. Athirdtype of emissivedeviceisthe light-emitting diode ( LED). Amatrixof diodesisarranged toformthe pixel positionsin the display,and picturedefinition isstored in arefreshbuffer.Asin scan-line refreshing of aCRT,information is readfrom the refreshbufferand converted tovoltage levelsthatareapplied to the diodestoproducethe lightpatternsin the display. Liquid-crystaldisplays ( LCDs)arecommonlyused in small systems,suchas laptop computers and calculators (Fig. 2-14). Thesenonemissivedevicesproduce apicturebypassing polarized lightfrom the surroundingsorfrom aninternal lightsourcethrough aliquid-crystalmaterialthatcanbealigned toeitherblock ortransmitthe light. The term liquid crystal refers tothe factthatthesecompoundshaveacrys- talline arrangementof molecules,yettheyflowlike aliquid. Flat-panel displays commonlyusenematic(threadlike) liquid-crystalcompoundsthattend tokeep the long axesof the rod-shaped moleculesaligned. Aflat-panel displaycanthen beconstructed withanematicliquid crystal,asdemonstrated in Fig. 2-15. Two glass plates,eachcontaining alightpolarizerthatisaligned atarightangle tothe otherplate,sandwichthe liquid-crystalmaterial. Rows of horizontal,transparent conductors arebuiltintoone glass plate,and columnsof verticalconductors are put intothe otherplate. The intersection of twoconductors definesapixel posi- tion. Normally,the moleculesarealigned asshowninthe “on state” of Fig. 2-15. FIGURE 2-14 A Polarized lightpassing through the materialistwisted sothatitwill pass through handheld calculatorwithan the oppositepolarizer.The lightisthen reflected backtothe viewer.Toturnoff the LCD screen. ( Courtesy of Texas Instruments. )

Nematic Liquid Crystal Transparent Conductor Polarizer

Polarizer On State Transparent Conductor Nematic Liquid Crystal Transparent Conductor Polarizer

FIGURE 2-15 The light-twisting,shuttereffect Polarizer used in the design of most Off State Transparent liquid-crystaldisplaydevices. Conductor hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 Video DisplayDevices 47

pixel,weapplyavoltage tothe twointersecting conductors toalign the molecules sothatthe lightisnottwisted. Thistype of flat-panel deviceisreferred toasa passive-matrix LCD.Picturedefinitionsarestored in arefreshbuffer,and the screen isrefreshed atthe rateof60 framespersecond,asin the emissivede- vices.Backlighting isalsocommonlyapplied using solid-stateelectronicdevices, sothatthe system isnotcompletelydependenton outside lightsources.Colors canbedisplayed byusing differentmaterialsordyesand byplacing atriadof colorpixelsateachscreen location. Anothermethod forconstructing LCDsisto placeatransistorateachpixel location,using thin-film transistortechnology.The transistors areused tocontrol the voltage atpixel locationsand topreventcharge from graduallyleaking out of the liquid-crystalcells.Thesedevicesarecalled active-matrix displays.

Three-DimensionalViewing Devices Graphicsmonitors forthe displayof three-dimensionalsceneshavebeen de- vised using atechniquethatreflects aCRT image from avibrating,flexible mirror (Fig. 2-16). Asthe varifocalmirrorvibrates,itchangesfocallength. Thesevibra- tionsaresynchronized withthe displayof anobjecton aCRT sothateachpoint on the objectisreflected from the mirrorintoaspatialposition corresponding tothe distanceofthatpointfrom aspecified viewing location. Thisallows us to walk around anobjectorscene and viewitfrom differentsides. Figure2-17shows the GeniscoSpaceGraph system,whichusesavibrat- ing mirrortoprojectthree-dimensionalobjects intoa25-cmby25-cmby25-cm volume. Thissystem isalsocapable of displaying two-dimensionalcross-sectional

Projected 3D Image Timing and Control System Vibrating Flexible Mirror

CRT

Viewer

FIGURE 2-16 Operation of athree-dimensionaldisplay FIGURE 2-17 The SpaceGraph interactive system using avibrating mirrorthatchangesfocallengthto graphicssystem displays objects in three matchthe depthsof points in ascene. dimensionsusing avibrating,flexible mirror. ( Courtesy of GeniscoComputers Corporation.) hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

48 CHAPTER 2 Overviewof GraphicsSystems

“slices”ofobjects selected atdifferentdepths.Suchsystemshavebeen used in medicalapplicationstoanalyzedatafrom ultrasonographyand CATscandevices, in geologicalapplicationstoanalyzetopologicaland seismicdata, in design appli- cationsinvolving solid objects,and in three-dimensionalsimulationsof systems, suchasmoleculesand terrain.

Stereoscopicand Virtual-Reality Systems Anothertechniqueforrepresenting athree-dimensionalobjectistodisplaystereo- scopicviews of the object.Thismethod doesnotproducetruethree-dimensional images,but itdoesprovide athree-dimensionaleffectbypresenting adifferent viewtoeacheyeofanobserversothatscenesdo appeartohavedepth(Fig. 2-18). Toobtain astereoscopicprojection,wemust obtain twoviews of ascene generated withviewing directionsalong the linesfrom the position of eacheye (leftand right)tothe scene. Wecanconstructthe twoviews ascomputer-generated sceneswithdifferentviewing positions,orwecanuseastereo camerapairto photograph anobjectorscene. When wesimultaneouslylook atthe leftview withthe lefteyeand the rightviewwiththe righteye,the twoviews merge into asingle image and weperceiveascene withdepth. Figure2-19 shows twoviews of acomputer-generated scene forstereoscopicprojection. Toincreaseviewing comfort,the areasatthe leftand rightedgesof thisscene thatarevisible toonly one eyehavebeen eliminated. One waytoproduceastereoscopiceffecton arastersystem istodisplayeach of the twoviews on alternaterefreshcycles.The screen isviewed through glasses, witheachlensdesigned toactasarapidlyalternating shutterthatissynchronized toblockout one of the views.Figure2-20 shows apairof stereoscopicglasses constructed withliquid-crystalshutters and aninfrared emitterthatsynchronizes the glasseswiththe views on the screen. Stereoscopicviewing isalsoacomponentin virtual-reality systems,where users canstep intoascene and interactwiththe environment.Aheadset (Fig. 2-21) containing anopticalsystem togeneratethe stereoscopicviews can

FIGURE 2-18 Simulated viewing of astereoscopic projection. ( Courtesy of StereoGraphicsCorporation.) hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-1 Video DisplayDevices 49

(a)(b)

FIGURE 2-19 Astereoscopicviewing pair.(Courtesy of Jerry Farm.)

FIGURE 2-20 Glassesforviewing a FIGURE 2-21 Aheadsetused in virtual-reality systems. stereoscopicscene and aninfrared synchronizing ( Courtesy of VirtualResearch.) emitter.(Courtesy of StereoGraphicsCorporation.)

beused in conjunction withinteractiveinput devicestolocateand manipulate objects in the scene. Asensing system in the headsetkeepstrackofthe viewer’s position,sothatthe frontand backofobjects canbeseen asthe viewer“walks through” and interacts withthe display.Anothermethod forcreating avirtual- reality environmentistouseprojectors togenerateascene within anarrangement of walls,asin Figure2-22,whereaviewerinteracts withavirtualdisplayusing stereoscopicglassesand datagloves(Section 2-4). Lower-cost,interactivevirtual-reality environments canbesetupusing a graphicsmonitor,stereoscopicglasses,and ahead-tracking device. Figure2-23 shows anultrasound tracking devicewithsixdegreesof freedom. The track- ing deviceisplaced abovethe video monitorand isused torecordheadmove- ments,sothatthe viewing position forascene canbechanged asheadposition changes. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

50CHAPTER 2 Overviewof GraphicsSystems

FIGURE 2-22 Amolecularbiologist analyzing FIGURE 2-23 Anultrasound tracking device molecularstructuresinside avirtual-reality system used withstereoscopicglassestorecordchangesin called the Trimension ReaCTor.The “Fakespace aviewer’sheadposition. ( Courtesy of StereoGraphics Pinchgloves”enable the scientist tograspand Corporation.) rearrange virtualobjects in aprojected scene. ( Courtesy Silicon Graphics,Inc.and Trimension SystemsReaCTor. c 2003 SGI.All rights reserved.) [

2-2 RASTER-SCAN SYSTEMS

Interactiveraster-graphicssystemstypicallyemployseveralprocessing units.In addition tothe centralprocessing unit,orCPU, aspecial-purposeprocessor,called the video controller or displaycontroller, isused tocontrol the operation of the displaydevice. Organization of asimple rastersystem isshowninFig. 2-24. Here, the frame buffercanbeanywhereinthe system memory,and the video controller accessesthe frame buffertorefreshthe screen. Inaddition tothe video controller, moresophisticated rastersystemsemployotherprocessors ascoprocessors and accelerators toimplementvarious graphicsoperations.

Video Controller Figure2-25shows acommonlyused organization forrastersystems.Afixed area of the system memory isreserved forthe frame buffer,and the video controlleris given directaccess tothe frame-buffermemory. Frame-bufferlocations,and the corresponding screen positions,arerefer- enced in Cartesiancoordinates.Inanapplication program,weusethe commands

System Video CPU Monitor Memory Controller

System Bus

FIGURE 2-24 Architectureofasimple raster-graphicssystem. I/O Devices hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-2 Raster-ScanSystems 51

System Frame Video CPU Monitor Memory Buffer Controller

System Bus FIGURE 2-25 Architectureofaraster system withafixed portion of the system memory reserved I/O Devices forthe frame buffer.

Horizontal and Raster-Scan Vertical Deflection Generator Voltages

x y Register Register

y Pixel Memory Address Intensity Register

x Frame Buffer

FIGURE 2-26 ACartesian FIGURE 2-27 Basicvideo-controllerrefreshoperations. referenceframe withorigin atthe lower-leftcornerof avideo monitor.

within agraphicssoftwarepackage tosetcoordinatepositionsfordisplayed ob- jects relativetothe origin of the Cartesianreferenceframe. Often,the coordinate origin isreferenced atthe lower-leftcornerof ascreen displayareabythe software commands,although wecantypicallysetthe origin atanyconvenientlocation foraparticularapplication. Figure2-26 shows atwo-dimensionalCartesianref- erenceframe withthe origin atthe lower-leftscreen corner.The screen surfaceis then represented asthe first quadrantof atwo-dimensionalsystem,withpositive x valuesincreasing from lefttorightand positive y valuesincreasing from the bottom of the screen tothe top. Pixel positionsarethen assigned integer x values thatrange from 0to x max across the screen,lefttoright,and integer y valuesthat vary from 0to y max ,bottom totop. However,hardwareprocessessuchasscreen refreshing,aswell assome softwaresystems,referencethe pixel positionsfrom the top-leftcornerof the screen. InFig. 2-27,the basicrefreshoperationsof the video controlleraredia- grammed. Tworegisters areused tostorethe coordinatevaluesforthe screen hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

52CHAPTER 2 Overviewof GraphicsSystems

pixels.Initially,the x registerissetto0and the y registerissettothe value forthe top scanline. The contents of the frame bufferatthispixel position are then retrieved and used tosetthe intensity of the CRTbeam. Then the x reg- isterisincremented by1,and the process isrepeated forthe next pixel on the top scanline. Thisprocedurecontinuesforeachpixel along the top scanline. Afterthe last pixel on the top scanline hasbeen processed,the x registerisre- setto0and the y registerissettothe valueforthe next scanline downfrom the top of the screen. Pixelsalong thisscanline arethen processed in turn,and the procedureisrepeated foreachsuccessivescanline. Aftercycling through all pixelsalong the bottom scanline,the video controllerresets the registers tothe first pixel position on the top scanline and the refreshprocess starts over. Sincethe screen must berefreshed atarateofatleast 60 framespersecond, the simple procedureillustrated in Fig. 2-27 maynotbeaccommodated bytypical RAM chipsif the cycle time istoo slow.Tospeed uppixel processing,video controllers canretrievemultiple pixel valuesfrom the refreshbufferon eachpass. The multiple pixel intensitiesarethen stored in aseparateregisterand used to control the CRTbeamintensity foragroupofadjacentpixels.When thatgroup of pixelshasbeen processed,the next blockofpixel valuesisretrieved from the frame buffer. Avideo controllercanbedesigned toperformanumberof otheropera- tions.Forvarious applications,the video controllercanretrievepixel values from differentmemory areason differentrefreshcycles.Insome systems,for example,multiple frame buffers areoften provided sothatone buffercanbe used forrefreshing while pixel valuesarebeing loaded intothe otherbuffers. Then the currentrefreshbuffercanswitchroleswithone of the otherbuffers. Thisprovidesafast mechanismforgenerating real-time ,forex- ample,sincedifferentviews of moving objects canbesuccessivelyloaded into abufferwithout interrupting arefreshcycle. Anothervideo-controllertaskis the transformation of blocksof pixels,sothatscreen areascanbeenlarged, reduced,ormoved from one location toanotherduring the refreshcycles.In addition,the video controlleroften containsalookuptable,sothatpixel val- uesin the frame bufferareused toaccess the lookuptable insteadofcontrol- ling the CRTbeamintensity directly.Thisprovidesafast method forchanging screen intensity values,and lookuptablesarediscussed in moredetail in Chap- ter4. Finally,some systemsaredesigned toallowthe video controllertomixthe frame-bufferimage withaninput image from atelevision cameraorotherinput device.

Raster-ScanDisplayProcessor Figure2-28shows one waytoorganizethe components of arastersystem that containsaseparate displayprocessor, sometimesreferred toasa graphicscon- troller ora displaycoprocessor. The purposeofthe displayprocessoristofree the CPU from the graphicschores.Inaddition tothe system memory,aseparate display-processormemory areacanbeprovided. Amajortaskofthe displayprocessorisdigitizing apicturedefinition given in anapplication programintoasetof pixel valuesforstorage in the frame buffer. Thisdigitization process iscalled scanconversion. Graphicscommandsspec- ifying straightlinesand othergeometricobjects arescanconverted intoaset hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-2 Raster-ScanSystems 53

Display- Frame Video Processor Monitor Buffer Controller Memory

Display System CPU Processor Memory

System Bus FIGURE 2-28 Architectureofa raster-graphicssystem witha I/O Devices displayprocessor.

of discretepoints,corresponding toscreen pixel positions.Scanconverting a straight-line segment,forexample,meansthatwehavetolocatethe pixel po- sitionsclosest tothe line pathand storethe colorforeachposition in the frame buffer.Similarmethodsareused forscanconverting otherobjects in apicture definition. Characters canbedefined withrectangularpixel grids,asin Fig. 2-29, ortheycanbedefined withoutline shapes,asin Fig. 2-30.The arraysizefor charactergridscanvary from about 5by7to9by12ormoreforhigher-quality displays.Acharactergrid isdisplayed bysuperimposing the rectangulargrid patternintothe frame bufferataspecified coordinateposition. Forcharacters thataredefined asoutlines,the shapesarescanconverted intothe frame buffer bylocating the pixel positionsclosest tothe outline. Displayprocessors arealsodesigned toperformanumberof additionalop- erations.Thesefunctionsinclude generating various line styles(dashed,dotted, orsolid),displaying colorareas,and applying transformationstothe objects in a scene. Also,displayprocessors aretypicallydesigned tointerfacewithinteractive input devices,suchasamouse. FIGURE 2-29 Acharacter Inaneffort toreducememory requirements in rastersystems,methods defined asarectangulargrid of pixel positions. havebeen devised fororganizing the frame bufferasalinked list and encod- ing the colorinformation. One organization scheme istostoreeachscanline asasetof numberpairs.The first numberin eachpaircanbeareferenceto acolorvalue,and the second numbercanspecifythe numberof adjacentpix- elson the scanline thataretobedisplayed in thatcolor.Thistechnique,called run-lengthencoding, canresultin aconsiderable saving in storage spaceifa pictureistobeconstructed mostlywithlong runsof asingle coloreach. A similarapproachcanbetaken when pixel colors change linearly.Anotherap- proachistoencode the rasterasasetof rectangularareas( cell encoding). The disadvantagesof encoding runsarethatcolorchangesaredifficulttorecord and storage requirements increaseasthe lengthsof the runsdecrease. Inad- dition,itisdifficultforthe displaycontrollertoprocess the rasterwhen many short runsareinvolved. Moreover,the sizeofthe frame bufferisno longera majorconcern,becauseofsharpdeclinesin memory costs.Nevertheless,en- FIGURE 2-30 Acharacter coding methodscanbeusefulinthe digitalstorage and transmission of picture defined asanoutline shape. information. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

54 CHAPTER 2 Overviewof GraphicsSystems

2-3 GRAPHICS WORKSTATIONS AND VIEWING SYSTEMS

Most graphicsmonitors todayoperateasraster-scandisplays,and bothCRT and flat-panel systemsareincommon use. Graphicsworkstationsrange from small general-purposecomputersystemstomulti-monitorfacilities,often with ultra-large viewing screens.Forapersonalcomputer,screen resolutionsvary from about 640by480to1280by1024,and diagonalscreen lengthsmeasurefrom 12inchestoover21inches.Most general-purposesystemsnowhaveconsider- able colorcapabilities,and manyarefull-colorsystems.Foradesktop workstation specificallydesigned forgraphicsapplications,the screen resolution canvary from 1280by1024toabout 1600 by1200,withatypicalscreen diagonalof18inches ormore. Commercialworkstationscanalsobeobtained withavariety of devices forspecificapplications.Figure2-31shows the featuresin one type of artist’s workstation. High-definition graphicssystems,withresolutionsupto2560 by2048,are commonlyused in medicalimaging,air-trafficcontrol,simulation,and CAD.A 2048 by2048 flat-panel displayisshowninFig. 2-32. Manyhigh-end graphicsworkstationsalsoinclude large viewing screens, often withspecialized features.Figure2-33 shows alarge-screen system forstereo- scopicviewing,and Fig. 2-34isamulti-channel wide-screen system. Multi-panel displayscreensareused in avariety of applicationsthatrequire “wall-sized” viewing areas.Thesesystemsaredesigned forpresenting graphics displays atmeetings,conferences,conventions,trade shows,retail stores,mu- seums,and passengerterminals.Amulti-panel displaycanbeused toshow alarge viewof asingle scene orseveralindividualimages.Eachpanel in the system displays one section of the overall picture,asillustrated in Fig. 2-35. Large graphicsdisplays canalsobepresented on curved viewing screens,suchas the system in Fig. 2-36.Alarge,curved-screen system canbeusefulforview- ing byagroupofpeople studying aparticulargraphicsapplication,suchas the examplesin Figs.2-37 and 2-38. Acontrol center,featuring abattery of

FIGURE 2-31 Anartist’sworkstation,featuring FIGURE 2-32 Ahigh- amonitor,akeyboard,agraphicstabletwitha resolution (2048 by2048) hand cursor,and alighttable,in addition todata graphicsmonitor.(Courtesy of storage and telecommunicationsdevices.(Courtesy BarcoView. ) of DICOMED Corporation.) hearn-50265;ISBN: 0-13-015390-7 book August 15,2003 15:40

2-3 GraphicsWorkstationsand Viewing Systems 55

FIGURE 2-33 The SGI Reality Center2000D, FIGURE 2-34 Awide-screen viewof a featuring anImmersaDeskR2and displaying a molecularsystem displayed on the three-channel large-screen stereoscopicviewof pressurecontours SGI Reality Center3300W.(Courtesy of Silicon in avascularblood-flowsimulation superimposed Graphics,Inc.and MolecularSimulations. c 2003 on avolume-rendered anatomicdataset.(Courtesy SGI.All rights reserved.) [ of Silicon Graphics,Inc.and ProfessorCharlesTaylor, StanfordUniversity. c 2003 SGI.All rights reserved.) [

FIGURE 2-35 Amulti-panel displaysystem FIGURE 2-36 Ahomeland security study called the “SuperWall”. ( Courtesy of RGB Spectrum.) displayed using asystem withalarge curved viewing screen. ( Courtesy of Silicon Graphics,Inc. c 2003.All rights reserved.) [

standardmonitors,allows anoperatortoviewsectionsof the large displayand tocontrol the audio,video,lighting,and projection systemsusing atouch-screen menu.The system projectors provide aseamless,multichannel displaythatin- cludesedge blending, correction,and colorbalancing. And asurround- sound system isused toprovide the audio environment.Fig 2-39shows a360◦ paneled viewing system in the NASA control-towersimulator,whichisused fortraining and fortesting ways tosolveair-trafficand runwayproblemsat airports. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

56CHAPTER 2 Overviewof GraphicsSystems

FIGURE 2-37 A curved-screen graphics system displaying an interactivewalk-through of a naturalgasplant.(Courtesy of Silicon Graphics,Inc., Trimension Systems,and the Cadcentre,Cortaillod, Switzerland. c 2003 SGI. All rights rese[ rved.)

FIGURE 2-38 A geophysicalvisualization presented on a25-foot semicircularscreen,which providesa160◦ horizontal and 40 ◦ verticalfield of view. ( Courtesy of Silicon Graphics, Inc.,the LandmarkGraphics Corporation,and Trimension Systems. c 2003 SGI.All rights reserved.) [

FIGURE 2-39 The 360◦ viewing screen in the NASA airport control-tower simulator,called the FutureFlightCentralFacility. ( Courtesy of Silicon Graphics, Inc.and NASA. c 2003 SGI. All rights reserved.[ ) hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-4 Input Devices 57

2-4 INPUT DEVICES

Graphicsworkstationscanmake useofvarious devicesfordatainput.Most sys- temshaveakeyboardand one ormoreadditionaldevicesspecificallydesigned for interactiveinput.Theseinclude amouse,trackball,spaceball,and joystick. Some otherinput devicesused in particularapplicationsaredigitizers,dials,button boxes,datagloves,touchpanels,image scanners,and voicesystems.

Keyboards,Button Boxes,and Dials Analphanumeric keyboard on agraphicssystem isused primarilyasadevicefor entering text strings,issuing certain commands,and selecting menuoptions.The keyboardisanefficientdeviceforinputting suchnongraphicdataaspicturelabels associated withagraphicsdisplay.Keyboardscanalsobeprovided withfeatures tofacilitateentry of screen coordinates,menuselections,orgraphicsfunctions. Cursor-control keys and function keys arecommon featureson general- purposekeyboards.Function keys allowusers toselectfrequentlyaccessed opera- tionswithasingle keystroke,and cursor-control keys areconvenientforselecting adisplayed objectoralocation bypositioning the screen cursor.Akeyboardcan alsocontain othertypesof cursor-positioning devices,suchasatrackball orjoy- stick,along withanumerickeypadforfast entry of numericdata.Inaddition to thesefeatures,some keyboardshaveanergonomicdesign (Fig. 2-40)thatprovides adjustments forrelieving operatorfatigue. Forspecialized tasks,input toagraphicsapplication maycome from asetof buttons,dials,orswitchesthatselectdatavaluesorcustomized graphicsopera- tions.Figure2-41 givesanexample of a button box and asetof input dials. Buttons and switchesareoften used toinput predefined functions,and dialsarecommon devicesforentering scalarvalues.Numericalvalueswithin some defined range areselected forinput withdialrotations.Apotentiometerisused tomeasuredial rotation,whichisthen converted tothe corresponding numericalvalue.

MouseDevices Figure2-40illustratesatypicaldesign forone-button mouse, whichisasmall hand-held unitthatisusuallymoved around on aflatsurfacetoposition the screen cursor.Wheelsorrollers on the bottom of the mousecanbeused torecord the amountand direction of movement.Anothermethod fordetecting mouse

FIGURE 2-40 Ergonomicallydesigned keyboardwithremovable palm rests.The slope of each half of the keyboardcanbe adjusted separately.Aone- button mouse,showninfront of the keyboard,hasacable attachmentforconnection to the main computerunit. ( Courtesy of Apple Computer, Inc. ) hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

58 CHAPTER 2 Overviewof GraphicsSystems

(a)(b)

FIGURE 2-41 Abutton box(a)and asetof input dials(b). ( Courtesy of VectorGeneral.)

FIGURE 2-42 The Zmouse featuresthree buttons,amouseball underneath,athumbwheel on the side,and atrackball on top. ( Courtesy of the MultipointTechnology Corporation.)

motion iswithanopticalsensor.Forsome opticalsystems,the mouseismoved overaspecialmousepadthathasagrid of horizontaland verticallines.The opticalsensordetects movementacross the linesin the grid. Otheropticalmouse systemscanoperateonanysurface. And some arecordless,communicating with computerprocessors using digitalradio technology. Sinceamousecanbepicked upand put downatanotherposition without change in cursormovement,itisused formaking relativechangesin the position of the screen cursor.One,two,three,orfour buttonsareincluded on the top of the mouseforsignaling the execution of operations,suchasrecording cursor position orinvoking afunction. Most general-purposegraphicssystemsnow include amouseand akeyboardasthe primary input devices. Additionalfeaturescanbeincluded in the basicmousedesign toincrease the numberof allowable input parameters.The ZmouseinFig. 2-42hasthree buttons,athumbwheel on the side,atrackball on the top,and astandardmouse hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-4 Input Devices 59

ball underneath. Thisdesign providessixdegreesof freedom toselectspatial positions,rotations,and otherparameters.Withthe Zmouse,wecanselectan objectdisplayed on avideo monitor,rotateit,and moveitin anydirection. We could alsousethe Zmousetonavigateour viewing position and orientation through athree-dimensionalscene. Applicationsof the Zmouseinclude virtual reality,CAD, and .

Trackballsand Spaceballs A trackball isaball devicethatcanberotated withthe fingers orpalm of the hand toproducescreen-cursormovement.Potentiometers,connected tothe ball,mea- surethe amountand direction of rotation. Laptop keyboardsareoften equipped withatrackball toeliminatethe extraspacerequired byamouse. Atrackball can bemounted alsoonotherdevices,suchasthe ZmouseshowninFig. 2-42,or itcanbeobtained asaseparateadd-on unitthatcontainstwoorthree control buttons. Anextension of the two-dimensionaltrackball conceptisthe spaceball (Fig. 2-44),whichprovidessixdegreesof freedom. Unlike the trackball,aspaceball doesnotactuallymove. Strain gaugesmeasurethe amountof pressureapplied to the spaceball toprovide input forspatialpositioning and orientation asthe ball is pushed orpulled in various directions.Spaceballsareused forthree-dimensional positioning and selection operationsin virtual-reality systems,modeling,anima- tion,CAD, and otherapplications.

Joysticks Anotherpositioning deviceisthe joystick, whichconsists of asmall,verticallever (called the stick) mounted on abase. Weusethe joysticktosteerthe screen cursor around. Most joysticks,suchasthe unitin Fig. 2-43,selectscreen positionswith actualstickmovement; others respond topressureonthe stick. Some joysticks aremounted on akeyboard,and some aredesigned asstand-alone units. The distancethatthe stickismoved in anydirection from its centerpo- sition correspondstothe relativescreen-cursormovementin thatdirection.

FIGURE 2-43 Amovable joystick. ( Courtesy of the CalComp Group,Sanders Associates,Inc. ) hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

60 CHAPTER 2 Overviewof GraphicsSystems

Potentiometers mounted atthe baseofthe joystickmeasurethe amountof move- ment,and springsreturnthe sticktothe centerposition when itisreleased. One ormorebuttonscanbeprogrammed toactasinput switchestosignalactionsthat aretobeexecuted onceascreen position hasbeen selected. Inanothertype of movable joystick,the stickisused toactivateswitchesthat causethe screen cursortomoveataconstantrateinthe direction selected. Eight switches,arranged in acircle,aresometimesprovided sothatthe stickcanselect anyone of eightdirectionsforcursormovement.Pressure-sensitivejoysticks,also called isometricjoysticks, haveanon-movable stick. Apushorpull on the stickis measured withstrain gaugesand converted tomovementof the screen cursorin the direction of the applied pressure.

DataGloves Figure2-44 shows a dataglove thatcanbeused tograspa“virtualobject”. The gloveisconstructed withaseriesof sensors thatdetecthand and fingermotions. Electromagneticcoupling between transmitting antennasand receiving antennas areused toprovide information about the position and orientation of the hand. The transmitting and receiving antennascaneachbestructured asasetof three mutuallyperpendicularcoils,forming athree-dimensionalCartesianreference system. Input from the gloveisused toposition ormanipulateobjects in avir- tualscene. Atwo-dimensionalprojection of the scene canbeviewed on avideo monitor,orathree-dimensionalprojection canbeviewed withaheadset.

Digitizers Acommon devicefordrawing,painting,orinteractivelyselecting positionsisa digitizer. Thesedevicescanbedesigned toinput coordinatevaluesin eithera two-dimensionalorathree-dimensionalspace. Inengineering orarchitectural applications,adigitizerisoften used toscanadrawing orobjectand toinput asetof discretecoordinatepositions.The input positionsarethen joined with straight-line segments togenerateanapproximation of acurveorsurfaceshape. One type of digitizeristhe graphicstablet (alsoreferred toasa datatablet ), whichisused toinput two-dimensionalcoordinatesbyactivating ahand cursor orstylus atselected positionson aflatsurface. Ahand cursorcontainscross hairs forsighting positions,while astylus isapencil-shaped devicethatispointed atpositionson the tablet.Figures2-45 and 2-46showexamplesof desktop and

FIGURE 2-44 Avirtual- reality scene,displayed on a two-dimensionalvideo monitor,withinput from a datagloveand aspaceball. ( Courtesy of The Computer GraphicsCenter,Darmstadt, Germany. ) hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-4 Input Devices 61

FIGURE 2-45 The SummaSketchIII desktop FIGURE 2-46 The Microgrid III tabletwith tabletwithasixteen-button hand cursor.(Courtesy asixteen-button hand cursor,designed for of SummagraphicsCorporation.) digitizing largerdrawings.(Courtesy of SummagraphicsCorporation.)

FIGURE 2-47 The NotePad FIGURE 2-48 Anartist’sdigitizersystem,witha desktop tabletwithstylus. pressure-sensitive,cordless stylus.(Courtesy of Wacom ( Courtesy of CalComp Digitizer TechnologyCorporation.) Division,apart of CalComp,Inc. )

floor-model tablets,using hand cursors thatareavailable withtwo,four,orsix- teen buttons.Examplesof stylus input withatabletareshowninFigs.2-47and 2-48. The artist’sdigitizing system in Fig. 2-48 useselectromagneticresonanceto detectthe three-dimensionalposition of the stylus.Thisallows anartist topro- ducedifferentbrushstrokesbyapplying differentpressurestothe tabletsurface. Tabletsizevariesfrom 12by12inchesfordesktop modelsto44by60inchesor hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

62 CHAPTER 2 Overviewof GraphicsSystems

largerforfloormodels.Graphicstablets provide ahighlyaccuratemethod for selecting coordinatepositions,withanaccuracythatvariesfrom about 0.2mm on desktop modelstoabout 0.05mmorless on largermodels. Manygraphicstablets areconstructed witharectangulargrid of wiresem- bedded in the tabletsurface. Electromagneticpulsesaregenerated in sequence along the wires,and anelectricsignalisinduced in awirecoil in anactivated stylus orhand-cursortorecordatabletposition. Depending on the technology, signalstrength,coded pulses,orphaseshifts canbeused todetermine the position on the tablet. An acoustic (or sonic ) tablet usessound wavestodetectastylus position. Ei- therstrip microphonesorpointmicrophonescanbeemployed todetectthe sound emitted byanelectricalsparkfrom astylus tip. The position of the stylus iscal- culated bytiming the arrivalofthe generated sound atthe differentmicrophone positions.Anadvantage of two-dimensionalacoustictablets isthatthe micro- phonescanbeplaced on anysurfacetoformthe “tablet”workarea.Forexample, the microphonescould beplaced on abook page while afigureonthatpage is digitized. Three-dimensionaldigitizers usesonicorelectromagnetictransmissionsto recordpositions.One electromagnetictransmission method issimilartothatem- ployed in the dataglove:acoupling between the transmitterand receiverisused tocomputethe location of astylus asitmovesoveranobjectsurface. Figure2-49 shows adigitizerrecording the locationsof positionson the surfaceofathree- dimensionalobject.Asthe points areselected on anonmetallicobject,awire-frame outline of the surfaceisdisplayed on the computerscreen. Oncethe surfaceout- line isconstructed,itcanberendered using lighting effects toproducearealistic displayof the object.Resolution forthissystem isfrom 0.8 mm to0.08mm,de- pending on the model.

Image Scanners Drawings,graphs,photographs,ortext canbestored forcomputerprocessing withan image scanner bypassing anopticalscanning mechanismoverthe

FIGURE 2-49 Athree- dimensionaldigitizing system forusewithApple Macintosh computers.(Courtesy of Mira Imaging.) hearn-50265;ISBN: 0-13-015390-7 book August 15,2003 15:40

2-4 Input Devices 63

information tobestored. The gradationsof grayscale orcolorarethen recorded and stored in anarray.Oncewehavethe internalrepresentation of apicture,we canapplytransformationstorotate,scale,orcrop the picturetoaparticularscreen area.Wecanalsoapplyvarious image-processing methodstomodifythe array representation of the picture. Forscanned text input,various editing operations canbeperformed on the stored documents.Scanners areavailable in avariety of sizesand capabilities.Asmall hand-model scannerisshowninFig. 2-50,while Figs.2-51 and 2-52showlargermodels.

FIGURE 2-50 Ahand-held scannerthatcanbeused toinput eithertext orgraphicsimages. ( Courtesy of Thunderware,Inc. )

(a)(b)

FIGURE 2-51 Desktop scanners:(a)drumscannerand (b)flatbed scanner.(Courtesy of Aztek,Inc.,Lake Forest,California. ) hearn-50265;ISBN: 0-13-015390-7 book August 19,2003 16:22

64CHAPTER 2 Overviewof GraphicsSystems

FIGURE 2-52 Awide-formatscanner. ( Courtesy of Aztek,Inc.,Lake Forest,California. )

(a)(b)

FIGURE 2-53 Plasmapanelswithtouchscreens.(Courtesy of PhotonicsSystems. )

TouchPanels Asthe name implies, touchpanels allowdisplayed objects orscreen positionsto beselected withthe touchofafinger.Atypicalapplication of touchpanelsisfor the selection of processing optionsthatarerepresented asamenuof graphical icons.Some monitors,suchasthe plasmapanelsshowninFig. 2-53,aredesigned withtouchscreens.Othersystemscanbeadapted fortouchinput byfitting a transparentdevice(Fig. 2-54) containing atouch-sensing mechanismoverthe video monitorscreen. Touchinput canberecorded using optical,electrical,or acousticalmethods. Opticaltouchpanelsemployaline of infrared light-emitting diodes(LEDs) along one verticaledge and along one horizontaledge of the frame. Lightdetec- tors areplaced along the oppositeverticaland horizontaledges.Thesedetectors areused torecordwhichbeamsareinterrupted when the panel istouched. The twocrossing beamsthatareinterrupted identifythe horizontaland verticalcoor- dinatesof the screen position selected. Positionscanbeselected withanaccuracy of about 1/4inch. Withcloselyspaced LEDs,itispossible tobreaktwohorizontal ortwoverticalbeamssimultaneously.Inthiscase,anaverage position between the twointerrupted beamsisrecorded. The LEDsoperateatinfrared frequencies sothatthe lightisnotvisible toauser. Anelectricaltouchpanel isconstructed withtwotransparentplatesseparated byasmall distance. One of the platesiscoated withaconducting material,and hearn-50265;ISBN: 0-13-015390-7 book August 14,2003 15:32

2-4 Input Devices 65

FIGURE 2-54 Resistivetouch-screen overlays. FIGURE 2-55 Alightpen withabutton ( Courtesy of Elo TouchSystems,Inc. ) activator.(Courtesy of InteractiveComputerProducts. )

the otherplateiscoated witharesistivematerial. When the outerplateistouched, itisforced intocontactwiththe innerplate. Thiscontactcreatesavoltage drop across the resistiveplatethatisconverted tothe coordinatevaluesof the selected screen position. Inacousticaltouchpanels,high-frequencysound wavesaregenerated in horizontaland verticaldirectionsacross aglass plate. Touching the screen causes part of eachwavetobereflected from the fingertothe emitters.The screen position atthe pointof contactiscalculated from ameasurementof the time interval between the transmission of eachwaveand its reflection tothe emitter.

LightPens Figure2-55 shows the design of one type of lightpen. Suchpencil-shaped devices areused toselectscreen positionsbydetecting the lightcoming from points on the CRTscreen. Theyaresensitivetothe short burst of lightemitted from the phosphorcoating atthe instantthe electron beamstrikesaparticularpoint.Other lightsources,suchasthe background lightin the room,areusuallynotdetected by alightpen. Anactivated lightpen,pointed ataspoton the screen asthe electron beamlights upthatspot,generatesanelectricalpulsethatcausesthe coordinate position of the electron beamtoberecorded. Aswithcursor-positioning devices, recorded light-pen coordinatescanbeused toposition anobjectortoselecta processing option. Although lightpensarestill withus,theyarenotaspopularastheyonce weresincetheyhaveseveraldisadvantagescompared tootherinput devicesthat havebeen developed. Forexample,when alightpen ispointed atthe screen,part of the screen image isobscured bythe hand and pen. And prolonged useofthe lightpen cancausearmfatigue. Also,lightpensrequirespecialimplementations forsome applicationssincetheycannotdetectpositionswithin blackareas.Tobe able toselectpositionsin anyscreen areawithalightpen,wemust havesome nonzerolightintensity emitted from eachpixel within thatarea.Inaddition,light penssometimesgivefalsereadingsduetobackground lighting in aroom.

VoiceSystems Speechrecognizers areused withsome graphicsworkstationsasinput devices forvoicecommands.The voicesystem input canbeused toinitiategraphics hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

66 CHAPTER 2 Overviewof GraphicsSystems

FIGURE 2-56 Aspeech- recognition system. ( Courtesy of Threshold Technology,Inc. )

operationsortoenterdata.Thesesystemsoperatebymatching aninput against apredefined dictionary of wordsand phrases. Adictionary issetupbyspeaking the command wordsseveraltimes.The system then analyzeseachwordand establishesadictionary of wordfrequency patterns,along withthe corresponding functionsthataretobeperformed. Later,when avoicecommand isgiven,the system searchesthe dictionary for afrequency-patternmatch. Aseparatedictionary isneeded foreachoperatorus- ing the system. Input foravoicesystem istypicallyspoken intoamicrophone mounted on aheadset,asin Fig. 2-56,and the microphone isdesigned tomini- mizeinput of background sounds.Voicesystemshavesome advantage overother input devices,sincethe attention of the operatorneed notswitchfrom one device toanothertoenteracommand.

2-5 HARD-COPY DEVICES

Wecanobtain hard-copyoutput forour imagesin severalformats.Forpresen- tationsorarchiving,wecansend image filestodevicesorservicebureaus that will produceoverheadtransparencies,35mm slides,orfilm. And wecanput our pictureson paperbydirecting graphicsoutput toaprinterorplotter. The quality of the picturesobtained from anoutput devicedependson dot sizeand the numberof dots perinch,orlinesperinch,thatcanbedisplayed. Toproducesmoothpatterns,higher-quality printers shiftdotpositionssothat adjacentdots overlap. Printers produceoutput byeitherimpactornonimpactmethods. Impact print- ers press formed characterfacesagainst aninked ribbon ontothe paper.Aline printerisanexample of animpactdevice,withthe typefacesmounted on bands, chains,drums,orwheels. Nonimpact printers and plotters uselasertechniques, ink-jetsprays,electrostaticmethods,and electrothermalmethodstogetimages ontopaper. Characterimpactprinters often havea dot-matrix printheadcontaining a rectangulararrayof protruding wirepins,withthe numberof pinsdependent upon the quality of the printer.Individualcharacters orgraphicspatternsare obtained byretracting certain pinssothatthe remaining pinsformthe patternto beprinted. Figure2-57shows apictureprinted on adot-matrixprinter. Ina laser device,alaserbeamcreatesacharge distribution on arotating drum coated withaphotoelectricmaterial,suchasselenium. Tonerisapplied tothe drumand then transferred topaper. Ink-jet methodsproduceoutput bysquirting ink in horizontalrows across aroll of paperwrapped on adrum. The electrically charged ink streamisdeflected byanelectricfield toproducedot-matrixpatterns. And an electrostatic deviceplacesanegativecharge on the paper,one complete hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-5 Hard-CopyDevices 67

FIGURE 2-57 Apicture generated on adot-matrix printer,illustrating howthe density of dotpatternscanbe varied toproducelightand darkareas.(Courtesy of Apple Computer,Inc. )

FIGURE 2-58 Adesktop pen plotterwitharesolution of 0.025mm. ( Courtesy of SummagraphicsCorporation.)

rowatatime across the sheet.Then the paperisexposed toapositivelycharged toner.Thiscausesthe tonertobeattracted tothe negativelycharged areas,where itadherestoproducethe specified output.Anotheroutput technologyisthe electrothermal printer.Withthesesystems,heatisapplied toadot-matrixprint headtooutput patternson heat-sensitivepaper. Wecangetlimited coloroutput on some impactprinters byusing different- colored ribbons.Nonimpactdevicesusevarious techniquestocombine three differentcolorpigments (cyan,magenta, and yellow)toproducearange of color patterns.Laserand electrostaticdevicesdepositthe three pigments on separate passes; ink-jetmethodsshootthe three colors simultaneouslyon asingle pass along eachprintline. Drafting layouts and otherdrawingsaretypicallygenerated withink-jetor pen plotters.Apen plotterhasone ormorepensmounted on acarriage,orcross- bar,thatspansasheetof paper.Penswithvarying colors and widthsareused toproduceavariety of shadingsand line styles.Wet-ink,ball-point,and felt-tip pensareall possible choicesforusewithapen plotter.Plotterpapercanlie flator itcanberolled ontoadrumorbelt.Crossbars canbeeithermovable orstationary, while the pen movesbackand forthalong the bar.The paperisheld in position using clamps,avacuum,oranelectrostaticcharge. Anexample of atable-top, flatbed pen plotterisgiven in Figure2-58,and alarger,roll-feed pen plotteris showninFig. 2-59. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

68CHAPTER 2 Overviewof GraphicsSystems

FIGURE 2-59 Alarge,roll-feed pen plotterwithanautomatic multicoloreight-pen changerand a resolution of 0.0127 mm. ( Courtesy of SummagraphicsCorporation.)

2-6 GRAPHICS NETWORKS

Sofar,wehavemainlyconsidered graphicsapplicationson anisolated system withasingle user.However,multiuserenvironments and computernetworksare nowcommon elements in manygraphicsapplications.Various resources,suchas processors,printers,plotters,and datafiles,canbedistributed on anetworkand shared bymultiple users. Agraphicsmonitoron anetworkisgenerallyreferred toasa graphicsserver, orsimplya server. Often,the monitorincludesstandardinput devicessuchasa keyboardand amouseortrackball. Inthatcase,the system canprovide input,as well asbeing anoutput server.The computeron the networkthatisexecuting a graphicsapplication programiscalled the client, and the output of the programis displayed on aserver.Aworkstation thatincludesprocessors,aswell asamonitor and input devices,canfunction asbothaserverand aclient. When operating on anetwork,aclientcomputertransmits the instructions fordisplaying apicturetothe monitor(server). Typically,thisisaccomplished by collecting the instructionsintopackets beforetransmission,insteadofsending the individualgraphicsinstructionsone atatime overthe network. Thus,graphics softwarepackagesoften contain commandsthataffectpackettransmission,as well asthe commandsforcreating pictures.

2-7 GRAPHICS ON THE INTERNET

Agreatdealofgraphicsdevelopmentisnowdone on the Internet, whichisa globalnetworkofcomputernetworks.Computers on the Internetcommunicate using TCP/IP ( transmission control protocol/ internetworking protocol). Inaddition, the World Wide Web providesahypertext system thatallows users tolocate and viewdocuments thatcancontain text,graphics,and audio. Resources,such asgraphicsfiles,areidentified bya uniformresourcelocator ( URL). EachURL, hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-8 GraphicsSoftware 69

sometimesalsoreferred toasauniversalresourcelocator,containstwoparts:(1) the protocol fortransferring the document,and (2)the serverthatcontainsthe documentand,optionally,the location (directory)onthe server.Forexample,the URL http://www.siggraph.org indicatesadocumentthatistobetransferred with the hypertext transferprotocol ( http )and thatthe serveriswww.siggraph.org,which isthe home page of the SpecialInterest GroupinGraphics(SIGGRAPH)ofthe Association forComputing Machinery.Anothercommon type of URL beginswith ftp://.Thisidentifiesan“ftpsite”,whereprogramsorotherfilescanbedownloaded using the file-transferprotocol. Documents on the Internetcanbeconstructed withthe Hypertext Markup Language ( HTML). The developmentof HTML provided asimple method for describing adocumentcontaining text,graphics,and references(hyperlinks) tootherdocuments.Although resourcescould bemade available using HTML and URL addressing,itwasdifficultoriginallytofind information on the Inter- net.Subsequently,the NationalCenterforSupercomputing Applications(NCSA) developed a“browser”called Mosaicthatmade iteasierforusers tosearchfor Webresources.The Mosaicbrowserlaterevolved intothe browsercalled Netscape Navigator. The Hypertext MarkupLanguage providesasimple method fordeveloping graphicson the Internet,but ithaslimited capabilities.Therefore,otherlanguages havebeen developed forinternetgraphicsapplications,and wediscuss these languagesin Section 2-8.

2-8 GRAPHICS SOFTWARE

Therearetwobroadclassificationsforcomputer-graphicssoftware:special- purposepackagesand generalprogramming packages.Special-purposepack- agesaredesigned fornonprogrammers who wanttogeneratepictures,graphs, orcharts in some application areawithout worrying about the graphicsproce- duresthatmightbeneeded toproducesuchdisplays.The interfacetoaspecial- purposepackage istypicallyasetof menus thatallows users tocommunicate withthe programsin theirownterms.Examplesof suchapplicationsinclude artist’spainting programsand various architectural,business,medical,and en- gineering CAD systems.Bycontrast,ageneralprogramming package provides alibrary of graphicsfunctionsthatcanbeused in aprogramming language such asC, C++,Java, orFortran. Basicfunctionsin atypicalgraphicslibrary include thoseforspecifying picturecomponents (straightlines,polygons,spheres,and otherobjects),setting colorvalues,selecting views of ascene,and applying rota- tionsorothertransformations.Some examplesof generalgraphicsprogramming packagesareGL (GraphicsLibrary),OpenGL, VRML (Virtual-Reality Modeling Language),Java2D, and Java3D.Asetof graphicsfunctionsisoften called a computer-graphicsapplication programming interface ( CG API),becausethe library providesasoftwareinterfacebetween aprogramming language (such asC++) and the hardware. Sowhen wewriteanapplication programinC++, the graphicsroutinesallowustoconstructand displayapictureonanoutput device.

CoordinateRepresentations Togenerateapictureusing aprogramming package,wefirst need togivethe geometricdescriptionsof the objects thataretobedisplayed. Thesedescriptions hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

70 CHAPTER 2 Overviewof GraphicsSystems

determine the locationsand shapesof the objects.Forexample,aboxisspecified bythe positionsof its corners (vertices),and asphereisdefined byits centerposi- tion and radius.Withfewexceptions,generalgraphicspackagesrequiregeomet- ricdescriptionstobespecified in astandard,right-handed,Cartesian-coordinate referenceframe (AppendixA). Ifcoordinatevaluesforapicturearegiven in some otherreferenceframe (spherical,hyperbolic, etc.),theymust beconverted toCartesiancoordinatesbeforetheycanbeinput tothe graphicspackage. Some packagesthataredesigned forspecialized applicationsmayallowuseofother coordinateframesthatareappropriateforthoseapplications. Ingeneral,severaldifferentCartesianreferenceframesareused in the pro- cess of constructing and displaying ascene. First,wecandefine the shapesof individualobjects,suchastreesorfurniture,within aseparatecoordinateref- erenceframe foreachobject.Thesereferenceframesarecalled modeling coor- dinates, orsometimes localcoordinates or mastercoordinates. Oncethe indi- vidualobjectshapeshavebeen specified,wecanconstruct(“model”) ascene byplacing the objects intoappropriatelocationswithin ascene referenceframe called world coordinates. Thisstep involvesthe transformation of the individual modeling-coordinateframestospecified positionsand orientationswithin the world-coordinateframe. Asanexample,wecould constructabicycle bydefining eachofits parts (wheels,frame,seat,handle bars,gears,chain,pedals)inasep- aratemodeling-coordinateframe. Then,the componentparts arefitted together in world coordinates.Ifbothbicycle wheelsarethe same size,weonlyneed todescribeone wheel in alocal-coordinateframe. Then the wheel description isfitted intothe world-coordinatebicycle description in twoplaces.Forscenes thatarenottoo complicated,objectcomponents canbesetupdirectlywithin the overall world-coordinateobjectstructure,bypassing the modeling-coordinate and modeling-transformation steps.Geometricdescriptionsin modeling coordi- natesand world coordinatescanbegiven in anyconvenientfloating-pointor integervalues,without regardforthe constraints of aparticularoutput device. Forsome scenes,wemightwanttospecifyobjectgeometriesin fractionsof afoot, while forotherapplicationswemightwanttousemillimeters,orkilometers,or light-years. Afterall parts of ascene havebeen specified,the overall world-coordinate description isprocessed through various routinesontoone ormoreoutput-device referenceframesfordisplay.Thisprocess iscalled the viewing pipeline. World- coordinatepositionsarefirst converted to viewing coordinates corresponding tothe viewwewantof ascene,based on the position and orientation of ahypothetical .Then objectlocationsaretransformed toatwo-dimensionalprojection of the scene,whichcorrespondstowhatwewill see on the output device. The scene isthen stored in normalized coordinates, whereeachcoordinatevalueis in the range from 1to1orin the range from 0to1,depending on the system. − Normalized coordinatesarealsoreferred toas normalized devicecoordinates, since using thisrepresentation makesagraphicspackage independentof the coordinate range foranyspecificoutput device. Wealsoneed toidentifyvisible surfacesand eliminatepictureparts outside of the boundsforthe viewwewanttoshowon the displaydevice. Finally,the pictureisscanconverted intothe refreshbufferof a rastersystem fordisplay.The coordinatesystemsfordisplaydevicesaregenerally called devicecoordinates, or screen coordinates in the caseofavideo monitor. Often,bothnormalized coordinatesand screen coordinatesarespecified in aleft- handed coordinatereferenceframe sothatincreasing positivedistancesfrom the xy plane (the screen,orviewing plane) canbeinterpreted asbeing fartherfrom the viewing position. hearn-50265;ISBN: 0-13-015390-7 book July30,2003 15:15

2-8 GraphicsSoftware 71

Viewing and Projection Coordinates

1 1 Modeling Video Monitor Coordinates

Normalized 1 Plotter World Coordinates Coordinates

Other Output

Device Coordinates

FIGURE 2-60 The transformation sequencefrom modeling coordinatestodevice coordinatesforathree-dimensionalscene. Objectshapescanbeindividuallydefined in modeling-coordinatereferencesystems.Then the shapesarepositioned within the world-coordinatescene. Next,world-coordinatespecificationsaretransformed through the viewing pipeline toviewing and projection coordinatesand then tonormalized coordinates.Atthe finalstep,individualdevicedrivers transferthe normalized- coordinaterepresentation of the scene tothe output devicesfordisplay.

Figure2-60 brieflyillustratesthe sequenceofcoordinatetransformationsfrom modeling coordinatestodevicecoordinatesforadisplaythatistocontain a viewof twothree-dimensionalobjects.Aninitialmodeling-coordinateposition ( x mc , y mc , z mc )inthisillustration istransferred toworld coordinates,then toview- ing and projection coordinates,then toleft-handed normalized coordinates,and finallytoadevice-coordinateposition ( x dc , y dc )withthe sequence:

( x , y , z ) ( x w , y w , z w ) ( x v , y v , z v ) ( x , y , z ) mc mc mc → c c c → c c c → pc pc pc ( x , y , z ) ( x , y ) → nc nc nc → dc dc

Devicecoordinates( x dc , y dc )areintegers within the range (0,0)to(x max , y max )for aparticularoutput device. Inaddition tothe two-dimensionalpositions( x dc , y dc ) on the viewing surface,depthinformation foreachdevice-coordinateposition is stored foruseinvarious visibility and surface-processing algorithms.

GraphicsFunctions Ageneral-purposegraphicspackage providesusers withavariety of functions forcreating and manipulating pictures.Theseroutinescanbebroadlyclassified according towhethertheydealwithgraphicsoutput,input,attributes,transfor- mations,viewing,subdividing pictures,orgeneralcontrol. The basicbuilding blocksforpicturesarereferred toas graphicsoutput primitives. Theyinclude characterstringsand geometricentities,suchaspoints, straightlines,curved lines,filled colorareas(usuallypolygons),and shapes defined witharrays of colorpoints.Additionally,some graphicspackagespro- vide functionsfordisplaying morecomplexshapessuchasspheres,cones,and cylinders.Routinesforgenerating output primitivesprovide the basictoolsfor constructing pictures. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

72 CHAPTER 2 Overviewof GraphicsSystems

Attributes arepropertiesof the output primitives; thatis,anattributede- scribeshowaparticularprimitiveistobedisplayed. Thisincludescolorspecifi- cations,line styles,text styles,and area-filling patterns. Wecanchange the size,position,ororientation of anobjectwithin ascene using geometrictransformations. Some graphicspackagesprovide anadditional setof functionsforperforming modeling transformations, whichareused tocon- structascene whereindividualobjectdescriptionsaregiven in localcoordinates. Suchpackagesusuallyprovide amechanismfordescribing complexobjects (such asanelectricalcircuitorabicycle) withatree (hierarchical) structure. Otherpack- agessimplyprovide the geometric-transformation routinesand leavemodeling detailstothe programmer. Afterascene hasbeen constructed,using the routinesforspecifying the object shapesand theirattributes,agraphicspackage projects aviewof the pictureonto anoutput device. Viewing transformations areused toselectaviewof the scene, the type of projection tobeused,and the location on avideo monitorwherethe viewistobedisplayed. Otherroutinesareavailable formanaging the screen displayareabyspecifying its position,size,and structure. Forthree-dimensional scenes,visible objects areidentified and the lighting conditionsareapplied. Interactivegraphicsapplicationsmake useofvarious kindsof input devices, including amouse,atablet,orajoystick. Input functions areused tocontrol and process the dataflowfrom theseinteractivedevices. Some graphicspackagesalsoprovide routinesforsubdividing apicturede- scription intoanamed setof componentparts.And otherroutinesmaybeavail- able formanipulating thesepicturecomponents in various ways. Finally,agraphicspackage containsanumberof housekeeping tasks,suchas clearing ascreen displayareatoaselected colorand initializing parameters.We canlump the functionsforcarrying out thesechoresunderthe heading control operations.

SoftwareStandards The primary goalofstandardized graphicssoftwareisportability.When packages aredesigned withstandardgraphicsfunctions,softwarecanbemoved easily from one hardwaresystem toanotherand used in differentimplementationsand applications.Without standards,programsdesigned forone hardwaresystem often cannotbetransferred toanothersystem without extensiverewriting of the programs. Internationaland nationalstandards-planning organizationsin manycoun- trieshavecooperated in aneffort todevelop agenerallyaccepted standardfor computergraphics.Afterconsiderable effort,thisworkonstandardsled tothe developmentof the GraphicalKernel System ( GKS)in1984. Thissystem was adopted asthe first graphicssoftwarestandardbythe InternationalStandards Organization ( ISO)and byvarious nationalstandardsorganizations,including the AmericanNationalStandardsInstitute ( ANSI). Although GKS wasoriginally designed asatwo-dimensionalgraphicspackage,athree-dimensionalGKS ex- tension wassoon developed. The second softwarestandardtobedeveloped and approved bythe standardsorganizationswas PHIGS ( Programmer’sHierarchi- calInteractiveGraphicsStandard ),whichisanextension of GKS.Increased ca- pabilitiesforhierarchicalobjectmodeling,colorspecifications,surfacerendering, and picturemanipulationsareprovided in PHIGS.Subsequently,anextension of PHIGS, called PHIGS+,wasdeveloped toprovide three-dimensionalsurface- rendering capabilitiesnotavailable in PHIGS. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-9 Introduction toOpenGL 73

Asthe GKS and PHIGS packageswerebeing developed,the graphicswork- stationsfrom Silicon Graphics,Inc.(SGI)became increasinglypopular.These workstationscame withasetof routinescalled GL ( GraphicsLibrary),which very soon became awidelyused package in the graphicscommunity.Thus GL became ade factographicsstandard. The GL routinesweredesigned forfast, real-time rendering,and soon thispackage wasbeing extended tootherhard- waresystems.Asaresult,OpenGL wasdeveloped asahardware-independent version of GL in the early1990s.Thisgraphicspackage isnowmaintained and updated bythe OpenGL ArchitectureReviewBoard, whichisaconsortiumof representativesfrom manygraphicscompaniesand organizations.The OpenGL library isspecificallydesigned forefficientprocessing of three-dimensionalap- plications,but itcanalsohandle two-dimensionalscene descriptionsasaspecial caseofthree dimensionswhereall the z coordinatevaluesare0. Graphicsfunctionsin anypackage aretypicallydefined asasetof specifica- tionsthatareindependentof anyprogramming language. A language binding isthen defined foraparticularhigh-level programming language. Thisbinding givesthe syntaxforaccessing the various graphicsfunctionsfrom thatlanguage. Eachlanguage binding isdefined tomake best useofthe corresponding language capabilitiesand tohandle various syntaxissues,suchasdatatypes,parameter passing,and errors.Specificationsforimplementing agraphicspackage in apar- ticularlanguage aresetbythe InternationalStandardsOrganization. The OpenGL bindingsforthe Cand C++ languagesarethe same. OtherOpenGL bindingsare alsoavailable,suchasthoseforAdaand Fortran. Inthe following chapters,weusethe C/C++ binding forOpenGL asaframe- workfordiscussing basicgraphicsconcepts and the design and application of graphicspackages.Example programsin C++ illustrateapplicationsof OpenGL and the generalalgorithmsforimplementing graphicsfunctions.

OtherGraphicsPackages Manyothercomputer-graphicsprogramming librarieshavebeen developed. Some provide generalgraphicsroutines,and some areaimed atspecificapplica- tionsorparticularaspects of computergraphics,suchasanimation,virtualreality, orgraphicson the Internet. Apackage called Open Inventor furnishesasetof object-oriented routinesfor describing ascene thatistobedisplayed withcallstoOpenGL.The Virtual-Reality Modeling Language ( VRML),whichbeganasasubsetof Open Inventor,allows us tosetupthree-dimensionalmodelsof virtualworldson the Internet.Wecan alsoconstructpictureson the Webusing graphicslibrariesdeveloped forthe Java language. With Java2D, wecancreatetwo-dimensionalsceneswithin Javaapplets, forexample. Orwecanproducethree-dimensionalwebdisplays with Java3D . And withthe RendermanInterface from the PixarCorporation,wecangenerate scenesusing avariety of lighting models.Finally,graphicslibrariesareoften provided in othertypesof systems,suchasMathematica, MatLab, and Maple.

2-9 INTRODUCTION TO OpenGL

Abasiclibrary of functionsisprovided in OpenGL forspecifying graphicsprim- itives,attributes,geometrictransformations,viewing transformations,and many otheroperations.Aswenoted in the last section,OpenGL isdesigned tobehard- wareindependent,thereforemanyoperations,suchasinput and output routines, hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

74CHAPTER 2 Overviewof GraphicsSystems

arenotincluded in the basiclibrary.However,input and output routinesand many additionalfunctionsareavailable in auxiliary librariesthathavebeen developed forOpenGL programs.

BasicOpenGL Syntax Function namesin the OpenGL basiclibrary (alsocalled the OpenGL core library)areprefixed with gl,and eachcomponentwordwithin afunction name hasits first lettercapitalized. The following examplesillustratethisnaming convention.

glBegin,glClear,glCopyPixels,glPolygonMode

Certain functionsrequirethatone (ormore) of theirarguments beassigned asymbolicconstantspecifying,forinstance,aparametername,avaluefora parameter,oraparticularmode. All suchconstants begin withthe uppercase letters GL.Inaddition,componentwordswithin aconstantname arewritten in capitalletters,and the underscore( )isused asaseparatorbetween all component wordsin the name. Following areafewexamplesof the severalhundred symbolic constants available forusewithOpenGL functions.

GL_2D,GL_RGB,GL_CCW, GL_POLYGON,GL_AMBIENT_AND_DIFFUSE

The OpenGL functionsalsoexpectspecificdatatypes.Forexample,an OpenGL function parametermightexpectavaluethatisspecified asa32-bit integer.But the sizeofanintegerspecification canbedifferenton differentma- chines.Toindicateaspecificdatatype,OpenGL usesspecialbuilt-in,data-type names,suchas

GLbyte,GLshort,GLint,GLfloat,GLdouble,GLboolean

Eachdata-type name beginswiththe capitalletters GL and the remainderof the name isastandarddata-type designation,written in lower-caseletters. Some arguments of OpenGL functionscanbeassigned valuesusing anarray thatlists asetof datavalues.Thisisanoption forspecifying alist of valuesasa pointertoanarray,ratherthanspecifying eachelementof the list explicitlyasa parameterargument.Atypicalexample of the useofthisoption isin specifying xyz coordinatevalues.

Related Libraries Inaddition tothe OpenGL basic(core) library,thereareanumberof associ- ated librariesforhandling specialoperations.The OpenGL Utility ( GLU)pro- videsroutinesforsetting upviewing and projection matrices,describing complex objects withline and polygon approximations,displaying quadricsand B-splines using linearapproximations,processing the surface-rendering operations,and othercomplextasks.Every OpenGL implementation includesthe GLU library, and all GLU function namesstart withthe prefix glu .Thereisalsoanobject- oriented toolkitbased on OpenGL, called Open Inventor, whichprovidesrou- tinesand predefined objectshapesforinteractivethree-dimensionalapplications. Thistoolkitiswritten in C++. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-9 Introduction toOpenGL 75

Tocreateagraphicsdisplayusing OpenGL, wefirst need tosetupa display window on our video screen. Thisissimplythe rectangularareaof the screen in whichour picturewill bedisplayed. Wecannotcreatethe displaywindow directlywiththe basicOpenGL functions,sincethislibrary containsonlydevice- independentgraphicsfunctions,and window-managementoperationsdepend on the computerweareusing. However,thereareseveralwindow-system li- brariesthatsupport OpenGL functionsforavariety of machines.The OpenGL Extension tothe XWindowSystem ( GLX)providesasetof routinesthatare prefixed withthe letters glX .Apple systemscanusethe Apple GL ( AGL)in- terfaceforwindow-managementoperations.Function namesforthislibrary are prefixed with agl.ForMicrosoftWindows systems,the WGL routinesprovide a Windows-to-OpenGL interface. Theseroutinesareprefixed withthe letters wgl. The Presentation ManagertoOpenGL ( PGL)isaninterfaceforthe IBM OS/2, whichusesthe prefix pgl forthe library routines.And the OpenGL Utility Toolkit ( GLUT)providesalibrary of functionsforinteracting withanyscreen-windowing system. The GLUT library functionsareprefixed with glut,and thislibrary also containsmethodsfordescribing and rendering quadriccurvesand surfaces. SinceGLUT isaninterfacetootherdevice-specificwindowsystems,wecan useGLUT sothatour programswill bedeviceindependent.Information regard- ing the latest version of GLUT and downloadproceduresforthe sourcecode are available atthe Website:

http://reality.sgi.com/opengl/glut3/glut3.html

HeaderFiles Inall of our graphicsprograms,wewill need toinclude the headerfile forthe OpenGL corelibrary.Formost applicationswewill alsoneed GLU.And weneed toinclude the headerfile forthe windowsystem. Forinstance,withMicrosoft Windows,the headerfile thataccessesthe WGL routinesis windows.h .This headerfile must belisted beforethe OpenGL and GLU headerfilesbecause itcontainsmacrosneeded bythe MicrosoftWindows version of the OpenGL libraries.Sothe sourcefile in thiscasewould begin with

#include #include #include

However,if weuseGLUT tohandle the window-managing operations,wedo notneed toinclude gl.h and glu.h becauseGLUT ensuresthatthesewill bein- cluded correctly.Thus,wecanreplacethe headerfilesforOpenGL and GLU with

#include

Wecould include gl.h and glu.h aswell,but doing sowould beredundantand could affectprogramportability. Inaddition,wewill often need toinclude headerfilesthatarerequired bythe C++ code. Forexample,

#include #include #include hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

76 CHAPTER 2 Overviewof GraphicsSystems

Withthe newISO/ANSI standardforC++,theseheaderfilesarecalled cstdio, cstdlib ,and cmath .

Display-WindowManagementUsing GLUT Togetstarted,wecanconsiderasimplified,minimalnumberof operationsfor displaying apicture. Sinceweareusing the OpenGL Utility Toolkit,our first step istoinitializeGLUT.Thisinitialization function could alsoprocess anycommand- line arguments,but wewill notneed tousetheseparameters forour first example programs.Weperformthe GLUT initialization withthe statement

glutInit(&argc, argv);

Next,wecanstatethatadisplaywindowistobecreated on the screen with agiven caption forthe title bar.Thisisaccomplished withthe function

glutCreateWindow("AnExample OpenGL Program");

wherethe single argumentforthisfunction canbeanycharacterstring wewant touseforthe display-windowtitle. Then weneed tospecifywhatthe displaywindowistocontain. Forthis, wecreateapictureusing OpenGL functionsand pass the picturedefinition to the GLUT routine glutDisplayFunc ,whichassignsour picturetothe display window.Asanexample,supposewehavethe OpenGL code fordescribing aline segmentin aprocedurecalled lineSegment .Then the following function call passesthe line-segmentdescription tothe displaywindow.

glutDisplayFunc(lineSegment);

But the displaywindowisnotyeton the screen. Weneed one moreGLUT function tocompletethe window-processing operations.Afterexecution of the following statement,all displaywindows thatwehavecreated,including their graphiccontent,arenowactivated.

glutMainLoop();

Thisfunction must bethe last one in our program. Itdisplays the initialgraphics and puts the programintoaninfiniteloop thatchecksforinput from devicessuch asamouseorkeyboard. Our first example will notbeinteractive,sothe program will just continuetodisplayour pictureuntil weclosethe displaywindow.In laterchapters,weconsiderhowwecanmodifyour OpenGL programstohandle interactiveinput. Although the displaywindowthatwecreated will beinsome defaultlocation and size,wecansettheseparameters using additionalGLUT functions.Weuse the glutInitWindowPosition function togiveaninitiallocation forthe top- leftcornerof the displaywindow.Thisposition isspecified in integerscreen coordinates,whoseorigin isatthe upper-leftcornerof the screen. Forinstance, the following statementspecifiesthatthe top-leftcornerof the displaywindow should beplaced 50pixelstothe rightof the leftedge of the screen and 100 pixels downfrom the top edge of the screen.

glutInitWindowPosition (50,100); hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-9 Introduction toOpenGL 77

Video screen 50 100 An Example OpenGL Program

Display Window

300

400 FIGURE 2-61 A400 by300 displaywindowatposition (50,100) relativetothe top-leftcornerof the video display.

Similarly,the glutInitWindowSize function isused tosetthe initialpixel widthand heightof the displaywindow.Thus,wespecifyadisplaywindow withaninitialwidthof400 pixelsand aheightof 300 pixels(Fig. 2-61) withthe statement

glutInitWindowSize(400,300);

Afterthe displaywindowison the screen,wecanreposition and resizeit. Wecanalsosetanumberof otheroptionsforthe displaywindow,suchas buffering and achoiceofcolormodes,withthe glutInitDisplayMode func- tion. Arguments forthisroutine areassigned symbolicGLUT constants.Forex- ample,the following command specifiesthatasingle refreshbufferistobeused forthe displaywindowand thatthe RGB (red,green,blue) colormode istobe used forselecting colorvalues.

glutInitDisplayMode(GLUT_SINGLE |GLUT_RGB);

The valuesof the constants passed tothisfunction arecombined using alogical or operation. Actually,single buffering and RGB colormode arethe defaultoptions. But wewill usethe function nowasareminderthatthesearethe optionsthatare setforour display.Later,wediscuss colormodesin moredetail,aswell asother displayoptionssuchasdouble buffering foranimation applicationsand selecting parameters forviewing three-dimensionalscenes.

ACompleteOpenGL Program Therearestill afewmoretaskstoperformbeforewehaveall the parts weneed for acompleteprogram. Forthe displaywindow,wecanchooseabackground color. And weneed toconstructaprocedurethatcontainsthe appropriateOpenGL functionsforthe picturethatwewanttodisplay. Using RGB colorvalues,wesetthe background colorforthe displaywindow tobewhite,asin Fig. 2-61,withthe OpenGL function

glClearColor(1.0,1.0,1.0,0.0); hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

78CHAPTER 2 Overviewof GraphicsSystems

The first three arguments in thisfunction seteachofthe red,green,and bluecom- ponentcolors tothe value1.0.Thus wegetawhitecolorforthe displaywindow. If,insteadof1.0,weseteachofthe componentcolors to0.0,wewould getablack background. And if eachofthe red,green,and bluecomponents weresettothe same intermediatevaluebetween 0.0and 1.0,wewould getsome shade of gray. The fourthparameterin the glClearColor function iscalled the alphavalue forthe specified color.One useforthe alphavalueisasa“blending” parameter. When weactivatethe OpenGL blending operations,alphavaluescanbeused todetermine the resulting colorfortwooverlapping objects.Analphavalueof 0.0indicatesatotallytransparentobject,and analphavalueof1.0indicatesan opaqueobject.Blending operationswill notbeused forawhile,sothe valueof alphaisirrelevanttoour earlyexample programs.Fornow,wesimplysetalpha to0.0. Although the glClearColor command assignsacolortothe displaywin- dow,itdoesnotput the displaywindowon the screen. Togetthe assigned window colordisplayed,weneed toinvoke the following OpenGL function.

glClear(GL_COLOR_BUFFER_BIT);

The argument GL COLOR BUFFER BIT isanOpenGL symbolicconstantspec- ifying thatitisthe bitvaluesin the colorbuffer(refreshbuffer)thataretobeset tothe valuesindicated in the glClearColor function. (Wediscuss otherbuffers in laterchapters.) Inaddition tosetting the background colorforthe displaywindow,wecan chooseavariety of colorschemesforthe objects wewanttodisplayin ascene. Forour initialprogramming example,wewill simplysetobjectcolortobered and deferfurtherdiscussion of the various coloroptionsuntil Chapter4:

glColor3f(1.0,0.0,0.0);

The suffix3fonthe glColor function indicatesthatwearespecifying the three RGB colorcomponents using floating-point( f )values.Thesevaluesmust bein the range from 0.0to1.0,and wehavesetred 1.0and green blue 0.0. = = = Forour first program,wesimplydisplayatwo-dimensionalline segment. Todothis,weneed totell OpenGL howwewantto“project”our pictureonto the displaywindow,becausegenerating atwo-dimensionalpictureistreated by OpenGL asaspecialcaseofthree-dimensionalviewing. So,although weonly wanttoproduceavery simple two-dimensionalline,OpenGL processesour picturethrough the full three-dimensionalviewing operations.Wecansetthe projection type (mode) and otherviewing parameters thatweneed withthe fol- lowing twofunctions.

glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0,200.0,0.0,150.0);

Thisspecifiesthatanorthogonalprojection istobeused tomapthe contents of atwo-dimensional(2D)rectangularareaof world coordinatestothe screen,and thatthe x -coordinatevalueswithin thisrectangle range from 0.0to200.0with y -coordinatevaluesranging from 0.0to150.0.Whateverobjects wedefine within thisworld-coordinaterectangle will beshownwithin the displaywin- dow.Anything outside thiscoordinaterange will notbedisplayed. Therefore, the GLU function gluOrtho2D definesthe coordinatereferenceframe within the hearn-50265;ISBN: 0-13-015390-7 book July29,2003 15:55

2-9 Introduction toOpenGL 79

FIGURE 2-62 The display windowand line segment produced bythe example program.

displaywindowtobe(0.0,0.0)atthe lower-leftcornerof the displaywindowand (200.0,150.0)atthe upper-rightwindowcorner.Sinceweareonlydescribing atwo-dimensionalobject,the orthogonalprojection hasno othereffectthanto “paste” our pictureintothe displaywindowthatwedefined earlier.Fornow,we will useaworld-coordinaterectangle withthe same aspectratio asthe display window,sothatthereisno distortion of our picture. Later,wewill considerhow wecanmaintain anaspectratio thatisnotdependentupon the display-window specification. Finally,weneed tocall the appropriateOpenGL routinestocreateour line seg- ment.The following code definesatwo-dimensional,straight-line segmentwith integer,Cartesianendpointcoordinates(180,15) and (10,145). InChapter3,we presentadetailed explanation of thesefunctionsand the otherOpenGL functions forgenerating graphicsprimitives.

glBegin (GL_LINES); glVertex2i(180,15); glVertex2i(10,145); glEnd();

Nowwearereadytoput all the piecestogether.The following OpenGL programisorganized intothree procedures.Weplaceall initializationsand related one-time parametersettingsin procedure init .Our geometricdescription of the “picture” wewanttodisplayisin procedure lineSegment ,whichisthe procedurethatwill bereferenced bythe GLUT function glutDisplayFunc . And the main procedurecontainsthe GLUT functionsforsetting upthe display windowand getting our line segmentontothe screen. Figure2-62 shows the displaywindowand red line segmentgenerated bythisprogram. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

80CHAPTER 2 Overviewof GraphicsSystems

#include // (orothers,depending on the system in use)

voidinit(void) { glClearColor(1.0,1.0,1.0,0.0); // Setdisplay-windowcolortowhite.

glMatrixMode(GL_PROJECTION); // Setprojection parameters. gluOrtho2D(0.0,200.0,0.0,150.0); }

voidlineSegment(void) { glClear(GL_COLOR_BUFFER_BIT); // Cleardisplaywindow.

glColor3f(1.0,0.0,0.0); // Setline segmentcolortored. glBegin (GL_LINES); glVertex2i(180,15); // Specifyline-segmentgeometry. glVertex2i(10,145); glEnd();

glFlush();//Process all OpenGL routinesasquicklyaspossible. }

voidmain (intargc, char** argv) { glutInit(&argc, argv); // InitializeGLUT. glutInitDisplayMode(GLUT_SINGLE |GLUT_RGB); // Setdisplaymode. glutInitWindowPosition (50,100); // Settop-leftdisplay-windowposition. glutInitWindowSize(400,300); // Setdisplay-windowwidthandheight. glutCreateWindow("AnExample OpenGL Program"); // Createdisplaywindow.

init();//Executeinitialization procedure. glutDisplayFunc(lineSegment); // Sendgraphicstodisplaywindow. glutMainLoop(); // Displayeverything andwait. }

Atthe end of procedure lineSegment isafunction, glFlush ,thatwe havenotyetdiscussed. Thisissimplyaroutine toforceexecution of our OpenGL functions,whicharestored bycomputersystemsin buffers in differ- entlocations,depending on howOpenGL isimplemented. Onabusy network, forexample,therecould bedelays in processing some buffers.But the call to glFlush forcesall suchbuffers tobeemptied and the OpenGL functionstobe processed. The procedure lineSegment thatwesetuptodescribeour pictureisre- ferred toasa displaycallbackfunction.And thisprocedureisdescribed asbeing “registered” by glutDisplayFunc asthe routine toinvoke wheneverthe dis- playwindowmightneed toberedisplayed. Thiscanoccur,forexample,if the displaywindowismoved. Insubsequentchapters wewill take alook atother typesof callbackfunctionsand the associated GLUT routinesthatweuseto registerthem. Ingeneral,OpenGL programsareorganized asasetof callback functionsthataretobeinvoked when certain actionsoccur. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

2-10 Summary 81

2-10 SUMMARY

Inthisintroductory chapter,wesurveyed the majorhardwareand softwarefea- turesof computer-graphicssystems.Hardwarecomponents include video moni- tors,hardcopyoutput devices,various kindsof input devices,and components for interacting withvirtualenvironments.Some softwaresystems,suchasCAD pack- agesand paintprograms,aredesigned forparticularapplications.Othersoftware systemsprovide alibrary of generalgraphicsroutinesthatcanbeused within a programming language suchasC++ togeneratepicturesforanyapplication. The predominantgraphicsdisplaydeviceisthe rasterrefreshmonitor,based on television technology.Arastersystem usesaframe buffertostorethe color valueforeachscreen position (pixel). Picturesarethen painted ontothe screen byretrieving thisinformation from the frame buffer(alsocalled arefreshbuffer) asthe electron beaminthe CRTsweepsacross eachscanline,from top tobot- tom. Oldervectordisplays constructpicturesbydrawing straight-line segments between specified endpointpositions.Pictureinformation isthen stored asaset of line-drawing instructions. Manyothervideo displaydevicesareavailable. Inparticular,flat-panel dis- playtechnologyisdeveloping atarapid rate,and thesedevicesarenowused in a variety of systems,including bothdesktop and laptop computers.Plasmapanels and liquid-crystaldevicesaretwoexamplesof flat-panel displays.Otherdis- playtechnologiesinclude three-dimensionaland stereoscopic-viewing systems. Virtual-reality systemscaninclude eitherastereoscopicheadsetorastandard video monitor. Forgraphicalinput,wehavearange of devicestochoosefrom. Keyboards, button boxes,and dialsareused toinput text,datavalues,orprogramming op- tions.The most popular“pointing” deviceisthe mouse,but trackballs,space- balls,joysticks,cursor-control keys,and thumbwheelsarealsoused toposition the screen cursor.Invirtual-reality environments,dataglovesarecommonlyused. Otherinput devicesareimage scanners,digitizers,touchpanels,lightpens,and voicesystems. Hardcopydevicesforgraphicsworkstationsinclude standardprinters and plotters,in addition todevicesforproducing slides,transparencies,and film out- put.Printers producehardcopyoutput using dot-matrix,laser,inkjet,electrostatic, orelectrothermalmethods.Graphsand charts canbeproduced withanink-pen plotterorwithacombination printer-plotterdevice. Standardgraphics-programming packagesdeveloped and approved through ISO and ANSI areGKS, 3DGKS, PHIGS, and PHIGS+. Otherpackagesthathave evolved intostandardsareGL and OpenGL.Manyothergraphicslibrariesare available foruseinaprogramming language,including Open Inventor,VRML, RenderMan,Java2D, and Java3D.Othersystems,suchasMathematica, MatLab, and Maple,often provide asetof graphics-programming functions. Normally,graphics-programming packagesrequirecoordinatespecifications tobegiven in Cartesianreferenceframes.Eachobjectforascene canbede- fined in aseparatemodeling Cartesian-coordinatesystem,whichisthen mapped toaworld-coordinatelocation toconstructthe scene. From world coordinates, three-dimensionalobjects areprojected toatwo-dimensionalplane,converted to normalized devicecoordinates,and then transformed tothe finaldisplay-device coordinates.The transformationsfrom modeling coordinatestonormalized de- vicecoordinatesareindependentof particularoutput devicesthatmightbeused in anapplication. Devicedrivers arethen used toconvert normalized coordinates tointegerdevicecoordinates. hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

82CHAPTER 2 Overviewof GraphicsSystems

Functionsthatareavailable in graphicsprogramming packagescanbedi- vided intothe following categories:graphicsoutput primitives,attributes,geo- metricand modeling transformations,viewing transformations,input functions, picture-structuring operations,and control operations. The OpenGL system consists of adevice-independentsetof routines(called the corelibrary),the utility library (GLU),and the utility toolkit(GLUT). Inthe auxiliary setof routinesprovided byGLU, functionsareavailable forgenerat- ing complexobjects,forparameterspecificationsin two-dimensionalviewing applications,fordealing withsurface-rendering operations,and forperforming some othersupporting tasks.InGLUT,wehaveanextensivesetof functionsfor managing displaywindows,interacting withscreen-windowsystems,and for generating some three-dimensionalshapes.WecanuseGLUT tointerfacewith anycomputersystem,orwecanuseGLX, Apple GL, WGL, oranothersystem- specificsoftwarepackage.

REFERENCES

Ageneraltreatmentof electronicdisplays isavailable in Tannas(1985) and in Sherr (1993). Flat-panel devicesarediscussed in Depp and Howard(1993). Additionalinformation on raster-graphicsarchitecturecanbefound in Foley,vanDam,Feiner,and Hughes(1990). Three-dimensionaland stereoscopicdisplays arediscussed in Johnson (1982)and in Grotch (1983). Head-mounted displays and virtual-reality environments arediscussed in Chung, etal. (1989). Standardsourcesforinformation on OpenGL areWoo,Neider,Davis,and Shreiner (1999) and Shreiner(2000). Open Inventorisexplored in Wernecke (1994). McCarthyand Descartes(1998) canbeconsulted fordiscussionsof VRML.Apresentation on RenderMan canbefound in Upstill (1989). Examplesof graphicsprogramming in Java2Daregiven in Knudsen (1999),Hardy(2000),and Horstmann and Cornell (2001). Graphicsprogramming using Java3Disexplored in Sowizral,Rushforth,and Deering (2000);Palmer(2001);Selman (2002);and Walshand Gehringer(2002). Forinformation on PHIGS and PHIGS+,see Howard,Hewitt,Hubbold,and Wyrwas (1991);Hopgood and Duce(1991);Gaskins(1992);and Blake (1993). Information on the two-dimensionalGKS standardand on the evolution of graphicsstandardsisavailable in Hopgood,Duce,Gallop,and Sutcliffe (1983). AnadditionalreferenceforGKS isEnderle, Kansy,and Pfaff (1984).

EXERCISES

2-1 List the operating characteristicsforthe following displaytechnologies:raster refreshsystems,vectorrefreshsystems,plasmapanels,and LCDs. 2-2List some applicationsappropriateforeachofthe displaytechnologiesin Exercise2-1. 2-3Determine the resolution (pixelspercentimeter)inthe x and y directionsforthe video monitorin useonyour system. Determine the aspectratio,and explain how relativeproportionsof objects canbemaintained on your system. 2-4 Considerthree differentrastersystemswithresolutionsof 640by480,1280by1024, and 2560 by2048. Whatsizeframe buffer(in bytes)isneeded foreachofthese systemstostore12bits perpixel? Howmuchstorage isrequired foreachsystem if 24bits perpixel aretobestored? 2-5 SupposeanRGB rastersystem istobedesigned using an8inchby10inchscreen witharesolution of 100 pixelsperinchineachdirection. Ifwewanttostore6bits hearn-50265;ISBN: 0-13-015390-7 book July29,2003 14:54

Exercises 83

perpixel in the frame buffer,howmuchstorage (in bytes)doweneed forthe frame buffer? 2-6Howlong would ittake toloada640-by-480frame bufferwith12bits perpixel, if 10 5 bits canbetransferred persecond? Howlong would ittake toloada24-bit- per-pixel frame bufferwitharesolution of 1280by1024using thissame transfer rate? 2-7Supposewehaveacomputerwith32 bits perwordand atransferrateof1mip (one million instructionspersecond). Howlong would ittake tofill the frame bufferof 1 a300 dpi (dotperinch) laserprinterwithapage sizeof8 / 2 inchesby11 inches? 2-8 Considertworastersystemswithresolutionsof 640by480and 1280by1024. How manypixelscould beaccessed persecond in eachofthesesystemsbyadisplay controllerthatrefreshesthe screen atarateof60 framespersecond? Whatisthe access time perpixel in eachsystem? 2-9 Supposewehaveavideo monitorwithadisplayareathatmeasures12inchesacross and 9.6incheshigh. Ifthe resolution is1280by1024and the aspectratio is1,what isthe diameterof eachscreen point? 2-10Howmuchtime isspentscanning across eachrowof pixelsduring screen refresh on arastersystem witharesolution of 1280by1024and arefreshrateof60 frames persecond? 2-11Consideranoninterlaced rastermonitorwitharesolution of n by m ( m scanlines and n pixelsperscanline),arefreshrateof r framespersecond,ahorizontalretrace time of t horiz ,and averticalretracetime of t v ert.Whatisthe fraction of the total refreshtime perframe spentin retraceofthe electron beam? 2-12Whatisthe fraction of the totalrefreshtime perframe spentin retraceofthe electron beamforanoninterlaced rastersystem witharesolution of 1280by1024,arefresh rateof60 Hz,ahorizontalretracetime of 5microseconds,and averticalretracetime of 500 microseconds? 2-13Assuming thatacertain full-color(24-bit-per-pixel) RGB rastersystem hasa512- by-512frame buffer,howmanydistinctcolorchoices(intensity levels)would we haveavailable? Howmanydifferentcolors could wedisplayatanyone time? 2-14 Comparethe advantagesand disadvantagesof athree-dimensionalmonitorusing avarifocalmirrortothoseofastereoscopicsystem. 2-15 List the differentinput and output components thataretypicallyused withvirtual- reality systems.Also,explain howusers interactwithavirtualscene displayed with differentoutput devices,suchastwo-dimensionaland stereoscopicmonitors. 2-16Explain howvirtual-reality systemscanbeused in design applications.Whatare some otherapplicationsforvirtual-reality systems? 2-17List some applicationsforlarge-screen displays. 2-18 Explain the differencesbetween ageneralgraphicssystem designed foraprogram- merand one designed foraspecificapplication,suchasarchitecturaldesign. 2-19 Explain the differencesbetween the OpenGL corelibrary,the OpenGL Utility,and the OpenGL Utility Toolkit. 2-20 Whatcommand could weusetosetthe colorof anOpenGL displaywindowto lightgray?Whatcommand would weusetosetthe colorof the displaywindowto black? 2-21List the statements needed tosetupanOpenGL displaywindowwhoselower-right cornerisatpixel position (200,200),withawindowwidthof100 pixelsand aheight of 75pixels. 2-22 Explain whatismeantbythe term“OpenGL displaycallbackfunction”.