Download as pdf
Download as pdf
You are on page 1of 59
MODULE 1 What is Computer Graphics? Explain the application of Computer Graphics. > Explain the operation of video monitors based on standard CRT design->'5 Differentiate raster scan displays and random scan displays. -5 = Explain the following > 38 a) Color CRT Monitors b) Flat panel Displays Explain the Architecture of a simple raster graphics system and a raster graphics system with a display processor. > th Explain the input devices. > 16 Explain the display window management using GLUT. —> 20 What is coordinate reference frames, screen coordinates, absolute and relative coordinates? >2 | 9. Explain the OpenGL functions for point and line. —» 22 10.Explain the DDA line drawing algorithm. —> 26 11. Explain the Bresenham’s Line drawing algorithm. —y 27 12. Explain the Bresenham's Midpoint circle drawing algorithm 73 3 13, Explain the Point attribute functions. » 35 14.List the OpenGL line attribute functions -» 36 15. List and explain OpenGL point and line primitive with example —> 38 16.Explain Cathode Ray Tube with diagram. — 40 17.With a neat diagram, explain Refresh Cathode Ray tubes 3 42 48. Implement an OpenGL program for Bresenham's line drawing algorithm. —> 44 19. Write short note on basic OpenGL syntax >) 5! 20.Explain properties of circle —> SQ 21.Implement midpoint circle draw in OpenGL —> 93 22.lmplement an OpenGL program to display points and lines along with its attribute functions included. —> 55° 23.Write Bresenham's line drawing Algorithm for |m| < 1.0 .Digitalize the line with endpoints (20,10) (3018) Fe oid. 24,Given a circle with radius=10 demonstrate the midpoint circle algorithm by determining positions along circle octant with first Quadrant from x=0 to x=y(Assume circle center is positioned at origin). 54 25.Apply Bresenham’s Line drawing algorithm for the given end points a)(20,20) and (40, 28) b)(0,0) to (5,4) ) (0,0) to (5,6) > el ReENS a exe MODULE 2 26.With neat diagram, explain the two commonly used algorithms for identifying interior areas of a plane figure. > 63 27. Explain two dimensional viewing transformation pipeline. —> 66 28. Show that successive scaling is muttipiicative. —» 64 29. Show that successive translations are additive. —> -\ 30. Design a polygon ABC ~ A(3,2), B(6,2) & C(6,6) rotate in anticlockwise direction by 30 degree by keeping C fixed. -» 43 31.What are world coordinates and view port coordinates? Explain 2D viewing transformation pipeline. —> 7! 32. Explain the scar-line polygon fill algorithm. 5 4 5” > Niacdual-Reoditt Lompiscgrumente A mene oan obhlicotion Lf CG is dn re ~cractbien VR ensiscommernta tin wohich a BUH YEON niemad voit arte objecte 255 cane - PPeccalised Sroviekisosca ‘ frovide Bb Nieuws te and Mowe the wusee SCe Baick suf ‘\ Bi Gn a Beene - i Lk ey vy LQucelisn rand Brains Couns Ne rooted col, Gindncial, Wsdition, aociol, at fs unk other Stem, axe sed As oe caida: Medeke 4 Bi “psvoconat, phyribe gical 6 of 9 Soe eapibanet atch a& 806% Bier qrorn J ; Shas kroorte commercial s0ftierse & gud 28 Lum ancl ounlyvodiien ee ee packages Ee ee cence" (sire) sroductions , meen (8 ese ee. the t Abe co. ands: omelirve® vncthoRs Amoges or combined phe acest and axome&, and sernetimer FW 4 One come onenckok i oer be oe ‘ an re pcien Tatuninpres WW) GUL Sa i ical pabivasa poonride ae 5 aver ctigovtrt 9 Galion stance gun manager AQT olReuse OF ASCIL Ke hvala vo hDEb le a rustindauss « » Image Procerai a certs ‘ otter octodiion wich ads ee dete soiphe ‘ound t te Mat Lonag Paola! a. AC woethedks, un Ce & Si A . as te Ne ey im Wt toe the ‘then # ose Marge ditty eK & d a aaa Bis eae f en ceg8 CG cds “OE ow a ppbet An Fmage Processing “GussKion as = Cordkuats fofemure . Todbroite a Picture the voerld coo dfuate refounce frog (2001 30) wuskbe Yelocterd. * Rods lijeck Lorqpoumettcad ceprdfucite 0 v92Hl or Ottior cath utey [die cles * Arectaugular wegfou cow pletely) eudoftug ar cijedschorackerfed lay tis confivcdeenet - Th ne Ys faulty colded a boondsiay va atu aD, a loonddiug yeckough : Soann Coordiuctey 3 * Sow coordiivctay Tdufy pire eu Teavouwn 0) Ys dFsyloy adavice Te "Y" cooaiuate Tanai © JetPowdor vcan WRue, Wietro* yc oordiuae dati fter a poxkosdar' Pree YW tos cour us, + Rondusoan typtcayy coukdtorod “the oppor yt comer a poitftou (0,0) bud We Ts oly tranfemuued logos x * We ull couwue TEX coord faytbe cQuitoy go Preah cdo. Alardiude aud Releiive Coordiuabe, § - ‘ Tuo coorauates weve bed wltug Tove at bean abredudte + TE wouldve easy however toupetify a cutout perttton, ancl tion we CcovdRuatey Huot com wdaiive totuat esouutpotttou- * for ecaunle, Y tux eoowud yoititon voy (5/2), tan the y@aatve coordi C2), caoudld refer Toten nouns ARQ otis abbots conrdsuato (3,6) . * Relative ccordtuaty cow wrelul yf use wasbrto can veveiad coptey ous objec Lathe wow qoowebic counpouards. We clucitbe Hie objed wituy coord? relative to aouue potud. Thor drowsiug tue objet nevera) oe diffouk cxoowst Ywiows cold eld, veveral Paoueoy coptey- qeeaplacn the open functions for pocnt and June oe ve cfertint (): function to sok the co-oidsnale valu gor gl pectin Hor the anf?) indi cdi thak xuftin ced are negprinedl fe this fonction th fam fa an Open —Apucificntion of a pant aw Gagin CAL —PomnT S); of vertex +0: gqpendt) cooiclinodiy ane quem wu stage pou Begin Car_PoInTs)? vertex 2i (S01 100); gfvevtenad (4510) yer fea Li (100,290) aferd 0% Altnatincy we Can wei pein aa auayt a iat pointiCd = Fs, 1004) tak pointe C1 Las, (8047 int porarat 2{ too, 2004) and GU thy opAnGL fundleory for platting th thu punts OA Begun CL POINTS)/ yer texrty point Di vertex rive point2)r ofverten div Cpornt 2) qpendoy 4k on gine th. co-odinatly w copies b= pot : Begin CL POINTS) | verter3¢(-7P+ 06, 909.42 14 60)) qivertense (260-411 S262 ,188-93)i qpend 4 ten alio fine act dad ot Auch for aque in got pou edi din Vonisus diimeniiany ty clo wc PEDDL publics GLfloot ay) yy A ‘ oss fini . ting | et | fnchion ruse could apy 0.30 welt coordina ent petition caith tk gilmerth uc Pt 20 point Poe; Porat por -% = 1204S] of ak pas = US 20) of eq in CQL pomrs) ¢ 31 give texat{ potnt fod-% point pos Wi end Or wl Gun we thy pend pant pletting funclisns within a crt pocdwu te amplonunt the mb pul Command: Opn dine funclions | a at of Aight hae acqmiunty xtmen tach Ancol pai of exdpeunt in 0 dist 9 guinalid ating athe prumitiy ui Cowtown GLALINES - ea me pans OE Requaled hank aa nigh rwlt in a clewd uch cxanyrle ‘ gleagin CUL-LInes)} opvert en aivl poi vey Fenriv Cp2)j verred 21 (pay yerkerriv Cen) vev ten riv(ps)i qeend GL-LINE ~ sTeiP iy ansthu function wd Jo display a du: otha gout dune Agunant un th patylu ip displayed bdwoun de fe and pant and acond ond pount pa deeord Line agement Js bdwan tH Atcond endpavtt and ctl tnd pourt and tho gor en A007 and 0 fosth: Begin (aL Line ste)! verter sive p Oi vertea siv(p2di verted aiv(pa)s verter iv (py)? open 23¥ py 4 end) ge Lead open dau yrimibiue 4s GL -LING—Loop , wich produc a dowd spebane examiles teen CULL NC_LooP)! yertexoiv( pos ghver tes atv >) vet Fexriv (P27 vertexriv Cpa) yer tem ai vepoi pend rs) to Explain the POF tute diewsing algetittin — Hla digital dpeunbiad arabs Ce Namie Jun, olgphithm baxd on Colouledtang within Sy ohn ay = mS oy ' ‘ te comidu pt a Low with position dope 1 ithe slope wy duh thon op egal tot rut ample at unit antiwel (8x21) tunol Ompube Au Coundine gp vals 7) Yur = Germ uboript FP Aeks tnlign volun steLting rm 0 pot th pat poent and inci ary by! unlil the fire} andpourd u readd fo ts with porlliie — alepe guests than +o we dou the ul & 7% anol y + that un, wt vample of until 4 antinvols Csy=0) and Coladak —comeculoe a volun as hes atte ech x vole iy rounded ty DR neon pine) | a RE ee 4outtn along fh, Outunt 4 Xan dene Ht the atoabing enantio the ipl than ity we fone Sxs-t and fet = Yur owt howe a! wth tery = dinilouy Gtadabibis ae Qnrisd oat osing Ge = Yet acl ayy =e od, 4 abipluk volar of the alope 6 La thon | and Pm stig pit Ho an apt we ond Ooldwlate Yves with Yer -Gutm Athen Da alttihg endpecay oso ate right wt ME Ss e-t and olttuin postions at Ae ert Uy Hg negattu dope asith abt etioty Value Quakes Shon 1 ux aye Fys-1 and Mer Ny ty Owe un 8y = ond eH hyd thy olgoritim ” mummarj tel Leusin id ine - Frincluce fabs Cay) ARPA = daba (dx) elas ateps = tobsCdy)i aincienent =Aloat Cx) [foot Cotepa)i ydincremant” = doo (aby) [ eloat(atepi) aac eine! (ound (x), woand Cy))i Bey( reo, He ores} bet) i Rt =adnevement yr qircreme nb mat Poiel Cyound (x), sound py } IYO: Explain Bresenham's Mine Drawing algorithm . dinu— of SHPAIGHE Cone Segment try A Scene is elefinedt by coordinate. positions fox the endpoints of the Segment: 5? display the line on a TeMEEr Monifor the graphics first project the enctpoints 40 Integer Screen coordinates cond cutermine the nearest pinel portions along fre Une path behoeen The hwo enctpoints tren the Une Gor] butter at he Cornesponding pixeb is Woaded indo tra Frame coordinates. 7A computed re potitions of (fo 48\20-51) Us Converted to pixet pation (10,284). This rouncting of Coordinates Valuer ro Integers CAs aU BA horidontnl and verticel inca je be atispeyed wy a Stare step APPUNance- Line Canations + The aMtetion Glope~intewapt Anation fr a SHAight lina is Wzmx+ec U0) with mas Ure Slee of He line and Ca» the 4 intercept. a Given Het the $0 eralpoints of A Une Schmene are. specified ad positions (eM) and Cheng Mend) 2% shoon in fig. Jwe alerrune Values for the Slope mm and C Sith the gpdlowiny Arttions - Ywe Consider Ml, mel and M7l CAs: wml | = X increments lanitwisely — PE Xe XH L then e - 4g = I aa te (end 4 z = 4s eee O44) 4) : a OTM Ye : ply = Yb OT ey = yy m7) Sub: e4n @ in Ay nA YS? abut) faye eT A Jo determing dhe VAL from (4, +14), fia dele we Cotenlete ocicion parameter (Ay) Faye mye) “et © 2 AA, = mace) FO-Yy — YW tm (mt) + — 1 Or Ama = 2M Cyr) — 24 12 —J ie bx (am(ayti— 9, ¢ 26-1) = AYO TH) — Dey, + 2aac— AL > P is He Injtind doc hon parameter in tquetion 4 encl in order 19 fined Combiners deciGion we have be find the wext Py. ney [Rear = ayCy 0) — 22 pet) ~My it eeac - 4] 5@ Be inenO snd Rnesn@ | Fay” ‘he LAY Cy) an (Yep Ie) or b, 4 Pk = DAY (fet ) 25% CO Me) ee Shankar R. pee TAY MOK deagon parameter we wit be Mothometicep oe meem aouyes between, de : "ih > ony an sre) And the preceeding aeeition parameter Ls Taye Py tray—san (yp > ¥y) 7@ awe Know Het Hee inition and et Us SnbStihete (yy Porametor Ox). > eqretion A bhevomes Ne 2Ay (ay th) — 20, +r (2Cy-ma) -1) OF Py DAY CHI) — Dany, -t Ox Coy —2M -1) or, Py = 2ay (112004) tay (oy, ama, —1) Ty Pye By (My AL) —ramyy + an (Ly) — 2By (ak) 4p 0% o& OF, Py PLOY ¢2dy — rays, + ayG) ayy — aH (R7FITF] Now: ppl aoove Dy only PAC initially : Point to be plotted is Cy 4p! WIN the tnitiab 10.4 Sor Cnebrurion fe if (% 20) } Ha ET) Sy? Met) eb 4 ape eet! De Coser: MS) & Y increments Units ele bey 4) ect | Birvilerly for Wr | care ano f= gan ray Ano] Peg Pp dan ody (% 4%) Concburion’ if (p 50) Wher? Net) yg PMT! eb, Seat! 5 My Carne di Me] aooth x GY increments “witwiselg . Mea oh) Dey 7 Bact) (32) EXPLAIN the Midpoint crete algoridinn (Se) Ans: Midpoint Girdle algorithm generates Ut poms oe metre ON a Circle Centered ab the origin by incrementing Au the Way Around Circle - 7 the Strategy is fe Select lohich of apixets & Closer ty dhe Circle by evel Ainthon at the miclpoimt Leboeen the pixels. Eight way Symmetry. Ake Shape vf th Circle is SIMUL in each 4yodre ~t herefore if We olekermine the Curve positions in the FISH GOAATANE) We Can Genorele the circle portions Wy the Second quacrant of ny plane-The circty Sections Ln the 4Bired anol Berth GQ ecdrant cen be Obtcinod from Sections in the Ast ancl Ind ee 2 Conatclering he Symmetry ateng X-AKIS te? A In this algorim ty evalneting afanctin/ YB BA the Wclppint Lehoenr thre > pixels we Con Arade which pixet is cleser ty the arcle - ae a te eds ond 1a! Symmcty of ) Stapp vse the Witiol point fc Coe Me) ei Omd ney pout Closer te jt Cod be Other fF Arete point Ome ap) oF (Ath, By -1) Oxy) Prone offers Yielca tre circle 4 Mydrpornt = (Meth AMT) fetnts cranes eH 2 for tho o}her : Crerrcyea,S) Seven ecteyts { 7) AS we howe Civele CAA on &s Wt yrer” (Me Cyt)? (y-YF —r 20 ) Unitial decision parameter and next could Le ae Peet = Crit!) 4 pg y=”? oe Pet (th ) lH) ar” \® ~) TO get centinnows Ae cisions, next P_ Contd be FU hth a 20% tt eg Ye Cg He) at A AMNitAl Avysjon paromeley at (0,1) is orl? 4-y) 2_y? Or) Py = lpr or) Pk = | ory Bee prs-¥ onpeer Coclwrions if (0) 20) 4 He et Yay =! 4 U ele 2 He He! Jean = Se aktsibute Functions Can Sek WO abtsibceter Fos points: colos ard Size ™ a state sytem, the chinptayed colos and Size of O poink 1% dokestorined by the cosrenk alu tose in the aktyibute List Glos components ara set wilh ROB vate as an ince into a colos tabli- Fos a xasten a pot Size 8 an integer eunttiple Of Hu pire Size, So tak a forge point % displayed os Q square block of pixels The displauged colos of a claignated point position is contaolld We cusownk colos valu in me state Lt. Also, a Coley 1% specified wih either the gfolos function ox Me gfincler function Se fe six fos an OpenGr point wilh we gf foinksize Csize)*, and fre point ia thon displayed os a sqpare block of pixels. Poorameder sie oxigned a positive floating - point value, which ?h ourdad to an ‘nderert (unten, the point ik to be antabiovtdl) The number of horizontal ond Notical pixels da the di of dhe point ik delermbad by parameter Site. Thus, a poink Size of 1-0 absplays 0 single pixel, ard a Poink Size of ho displays a axd pixel array tF UR activate the antialianing featur of OpenGL, Me sic of a Ait played block pixels willl be maditied to smooth rhe elgel The olebaule values fos point. Size 8 1-0 of be flirted inside os ouktich of g Abtvibute functions, Hoey nf ylEnd pais. Fao example, ths following code serment ploty tree Pomks in varying cba, and sized the Fight 4g Standland -$/ 2e Hod point, te second ik a Acuble- size gen pant, and te thisol th a .beipke-Size blue poink » gficodoa3é (1-0,0-0; 0-0); gl Begin (GL-Potnrs) ;, givortex a (50 » 100) 5 gb Pointsize (3-0); gkcoloo af (0-0, 1-0,0-0) 5 gerertexai (75, 150) 5 H Poinksize (3-0); Hcolow3# (0-0, 0-0)10), gfvectexai (100, 900) 5 Hendon; Lise the OpenGL Line aktsibuta Funetiont Conksol Whe appearance of a stzaight Line Ge con iN open@L, with jawee akbsibute. sektings - Segrunk 1- Line colos 9+ Lim width 3: dre style Line-widlh_ Function : pena with te function Line width is gltinewidih Cwidih) cosign Boating point value to paraniten width, and we : : thay value 1% nounced to the revert ronngative ae 7 eo 0-0, the Hine ie disp with a inpuk vale oun . din . however, oe pe the detauth : are $moothed whan antialiasing 4 to wadsice he get in Opentab the Line, its applied to pearance and fbanctionod is aster staix-step ap width axe passive, some inpfamontabions of fhe fing widih Function might Support a O Limited number of widlee and “some ight OL supra widim olnes, than to CFEC Line Study py 6 ee By debut a stoaigntline Segeank in display aL a solid fire However, we can aha dipley dashed Linck , clotked tines , % 4 Lin wih a combination of daskes ana clots , ard we Con vary Me length of tha dosh. ond the spacing between dosha, os dys we Se a coment dikploy Style too Lines with Ihe ORenG&L function gtinestipple C mepaakrockis , pattern | : ; cé fre ~Style Belove a Sine can be dixplayet in Mae Cunrar : es Paktemn, we must activate the Line-siyle feakure 9 We accomplish wilh the following Function gérable (GL-LINE-sT=ppLe) + SE we forge to inctude thy erable function solid Dinas are eAplorgeat 5 Mak 1% Ihe dihaule pattern Oxe Fre tA cael to Aisploy Ae any fre, ue can bun -o& he Line-pattem ding Seqrnants Feakine — with gyDiiobk C &rt-LEME-stxPpLE)) soplocs, cursent ine-styly pattern with Ihe aedat This Pattern Connecter Edthen Pine sie +A biom ab woctrons, amined fpewsing and dipbuien syskme # The phaphor tren emi a ama vuy Aapidly - Phanpherd actuated . Addl CRT. Aehuned be o> Hr gehts sah > Opuution of an slteHon gun ADefuiten wis educhen Fount ng, CoMepde Ande aa e ‘Shankar R ‘se Profesor, ‘CSE, BMSITEM Magnelic Phopher Ceald Sta Beam by an elicken gun, paras ecough tnat diact He biam rood spediked PoriKero ON the phosphor - tvakd scaun- ight a+ gach portion contakd by by He clevon bam and Me Aight emitted by He phrophor Sadr » One way te maintain Hw scxun pichme te fo shee Hu plete infor- Mavion ao a charge Auiibwisy wimin He C&T in ord te deep He » The moot common mined new employed fp. mainkdning phophn glow vo te redraw He pick mupiatedly by qickiy dixediay He ster bram bark aun Me same xe qien Poth. Ths Hype ef divplay ds cond * Th farquancy ak which a ple we Acdeown en Hex Scaun de with an arutvaling anode Clecken Bean Pah AL 48 ‘The patmary componen’ of an xiikien qun in CRT axe Hu heated mua catnede and a coniel qsid- © The heat supplied te Hu cathode by dixuing a cusent Hacough 4 col of wit, (00d Hu Blowunt, inids Wu ayiindatcal carnode Skudt . “the camu elution He be “beild off) Hy Wer colnede surface - * Gyoids He ERT cowslop, He Jeu, negabively changed Urcicens art Yon Acetild toward He pherpher coaling bY a Aigh pettus voting. eSnlewilly ef He etrckon beam Jo vankewd by Le verlag at He conkel gid. aos amount 6h Argue amined by phophor cealing dspend an the mon of alerors ciribing Ha sexun , Hu bsignines of a atoploy Poot a conteousd by varying, Hr voltage en He contol qaid. Te focusing sym ‘in a CRT Jous He akedapn btare ke Conuuge 4a small C19 siview oo dk skiky Hu phospher and ok us Acromplished with situ aleve 6 magni. Kebdo. |e Wott kereortalic Udousing, He aden bran Jo poosid Wncough & POiluly charged mubol eyindu 49 that +UK 0m aleng He wnbe Aine ah He opinda om tn 2gmidibstum goien : : + Ditvaton eb vu druxen btam can be conkewrd wikn si Han zed or magnic Judo. 5 * Catnsde-ray bubto axe wmmorly conokurkd wiPe hwo paws ob magnuit - Aufetion vio. * One pair jy mounkd on Hue for and belo Oh Hu CRT meek, Ard He OH par vo mound On eppeile stdin Oh Hu nick. * Tu mage Yeld pasduad by zach pour of wb xvutlo in a lawns dedtelion daw that Jo prpendtavar 18 bork re disstion of He magndic Lad and He dicen of Kaw) 6b rhe suchen biam. + Horizontal and vualteal dikuetions a acuonrpiished witty Hhtat paw of cab. [451 Implnunt an Opera Program Yo Bavsenhams dine daowting algeri thm. Atgert Hum \nal <4.0 Gavinhams Linm- Acawini 4. Input we hwo Anu andpeints and shoxt Hw Aett endpoint in Cre, Yo) fo ae Lee fo Yome- bulk peiton (40, 4.05 fey plot He Yast point - 3. Cateuta He Lombanls An, Ay,ady and @dy- 947, and eblain Me Ahouling value Aye He dacision paxamtla a po = dy- A% 4 At tak 1p along He Line, slauling ak R= 0, parvum He douewing tots Jk pReo, Hu ret point te plot te Cuttoy,) and Pras = Pet aby Olander We next point te plot de Capt yptt) and Pers = Pet Oy 28m 5+ Repent skp 4 An-4 meu Haw. o dn implimentalion of Bavenhan Aine algorithm Yo step tn tre Aang OSM < 1.0 wy given in Hu ASuewing prcudue . Endpert pikeX patton fy Hw Line ars poroid to Hnis proud, and pixels ars plovsd Kom Fre Jet andpeint Ho Hw aight 2ndpeint. H include H indude * Barnham dine-drawing prsaduar gm Im) < 1.0.) #/ void LineBaw (int x0, tat yo, int xEnd,int yend) \ dx = fabs (rend - 19), ay > fabs Cyend - 40) 5 prada dy-dns WwoPy = 2 ¥dy , kwe Dy Minusda mes = ae (ay -dx); ]* pammine which andpoint te we oy stort poritien. */ Gg (m0 >HEnd) { ne wend; 4% = YyEnd 5 HEnd = 10 5 5 ale f n= ndy 4 = yoy q auPixd Cn,y)5 white (7 < end) 1 mtr > uk (peo) pre bwoPys tor { yrty p t= bwoPyMtnus dx; t gurPixel Cry) J 3 (ox) sy indude # include int ah, yt, md, yey void daaw- pizel (int , int y) A gueotoray (4-0, 0-0) 5 gegin (OL ports) 5 givuakest Cyd gerd (5 TE 4 void banana Aine draw (int m4, iat yt, int ay, int ya) Shankar R. ‘Ase Profesor CSE. BMSITSM int dm sar-ndy int dyz yo- 4 ts int m= dy fda; U, (mes) A int duciston~ parame = 2¥dy- dns int weary ee te) uk (Ano) 4 nema; 4a42 5 meeats 5 AAaw. pied (n,y); while (n< na) { ay Cdedision- poramua > 0) {omeness ee dedvion— param = derivoien— paxomeect Aydy-ardye x(yrt-y), 3 woe 4 n=entiys 44s dacioion— pasomuer= daristen garam + 24 dy ~ de dna ly-y)) 5 drove - pleel Cayo 4 t alo Uh, Co >4) 4 ‘nt decvion- paramue = ay dx- ay; im’ az ats mr Y= yt; ay (dy co) { nenay 4 4; Yee yt q draw ptyet (my); while (ye ya) 4 Cdecsion — posamlu >=) LO neaess Ye yates decioien_ pasantlr = drision--pasamdH + 2% dn - i Ready we (nri-an); abs { teyety mm; dtcioien. paramtla = dicoian- pasamula + d4da- } ae dy (m-n)y \ diaw-. pixel Cus I aloe “ubCm s 24) 1 ine nant; ink Y= yty daa. pled (a, y) y while (x< x2) A N= arts ta yres . ( 1 Arana pixel Cay); oe [ga] ace veid init C) gear (oler (1,1, 1,1); Yuoiner (9.0, $00.0, 010, 500.0) 5 4 void Aisphay aUlear (Gr- CoLor- BYPFER_ B11); bawanhamo- Aine daavo Cat, yt, m4, ya) s PF Loh (Dy int main (int argc, char + argv) A prtnty C’ entu stact goin’ (a yt) \n") > seanh ("ta fd", amd, ytd) gaia (" Enter end pein (m3, ya)\n")5 scan} (fed a", ama, nyady qurinie (xarge, argv); gir Init DioplayMede Carvt-sineve | GLot- Row): que Twit Window sige (500,500); qurtnit Window Posivion (#20, 4 00) 5 qiurcarare Window (“Busenhomd Line Paawting’) 5 inte) 5 gkus Deploy Func Goplay); ghar MoinLoepl b QI9. trite shot nobe on basic OpenGL Syntax. nst- Basic Syntax i- @ ln order to write our first OpenGL prograrn, there are some things that we.should know. @AI functions in OpenGL use the pwefix “g|” ® Punetions from GLU and GLUT have the prefixes “alu” and “glut” respectively. @AI! constants fn OpenGL use the prefix “QL ie glBegin (GL POLYGON); Code exaumples— a wan (int arge pchar Be ogy) fulLait CF lutDat Dis pg Mode (GLU T_SINGLEIGLUT_R48), lubini tt lindo wd $ize(500,500); Jub sta t jebindiow Position (220,200), Gre evakistedenl"Bectonbanse Live Drawigs): intkOS gees ploy Fume Caisplay). (ee % Q20, Explain properties + Cirele. Anss~ Propertice of te Crrele in Corpules ; fap ho] y Ctrele ty defivd as a set points -that are all ata gtven distance fom a contng position Cx¢ Ne). WY UX xe JE +0 y-ye) Barr : wih Bregenhaw‘s [ine algorithm fos wetter dis play *s adapted to Circle qensnatioy by « Hing up the deerston Para roetens wh Finding the ¢losek pixel fo each fy. Ty) use could use this equation caleulole the position points on a circle Crim fexenc By stepping vd the x aos in Unit steps from? x... fo xetr ond caleulat +he oe valuts at enok pottben as Ys fod r® - Cee ~x)? vy adie Cercle equaton ty Pasxoustsic polar form Yreids the Paiy of equations XK 2Xe +rcoso + S=Yerrsine Sampling $ Dis Implement nidpoint circle draw in OpenGL. #include < stdio b> H include SQL glat b> int xhy yl, ms void daac pixel Cint x, int y) t gh@eyin CAL-PoInTs)s glventediCarxtay ty Os glénd 0; } void inst O f gt Clean Colon (4.0, 5.0, 1-0, 0'0); \ Colox 84 (0-0, 0:0, 0-0); LPomntSize (4-0); gi Matix Model 6 L-PROTECTION); gttead Iden HbyO; hu Ontho2d (0-0, 640-0, 0-0, 480.0); J void mid CineleAlge() t int x=0; ink yeas float decision = s/4 oy draw -~pirel (xs y)s fans yr if Cdecision < °) a nats decision +7 2% x 4; 4 elce year Kady decision +2 2% Lx~y) +1; 4 daaw-pixell x,y); duaw-pixell *, -15 daaw-pixetl-n,y 5 draw -picel (-x,-y)5 draw elly, x5 drao-preelly, x5 draw picelly,-*); draw- pixel l-y,-%); 5 void display) ‘ gh Cleon ( @L-COLOR- BUFFER. BIT); LColont4$le-o, 0-0, 0-0); gb Point Sirel so); mid CixcteAlgo O3 ghF leh; main(int ange, chan** angv) print Enter the co-ordinates eo] the conten :\n”)s seanf( “thd thd, bet, dy; print{” Enter the nadie ©); geanf (A a*, dad; gletinitla ange, angvds Lut Tait Display ModeCO Lut _simare | GLUT-RaB); git Tait Winclow Cize (G40, 48075 Lat Teil Window Porition (400, £0); glet Cneate Windowl Mid poink Circte Algorith”) ; yt Oe gletD 1 play Panel display); gletMainLeob 0s oa Twplement au OpenGt pacgram to Lic hla fo oad with it) attouibute Junations include Ft include AP inolade 0)d P=P 42x —2y. X= nt} 7 aa Framphe C200) de C3018) dn=to dy =8 De Ady - dure 2dy ~ 16 a 2 dy ~dad=-4 C2910) Ont Ye) C2) €22,12) a 42. - Cc. Digitization 2S 14 O43) B 6 s/1¥) (26/18) 27,16) Ly C2616) C30) 1$) @- 7 oe a eS wets padi =) he xu / fioserne eveeke COTE laomat ater ANS ls cr3e Kt 200 con _CS ° lle can just pola Che Valitse BO pact Gritial decision poramela ~ Sf. of (PK <0) maagr | f 7 9& h,, ee tlm 41H ~2y +) 0. Brenmhaw's Cirole Aigoritnn Cr= to thi k= wo Stgp 2 Mumbex \ 2 3 y S é > ® Bresenbom's Line dacs? a Mh ee C (CSE, BMSITaM (a) (3,20) snd C40,28) (¥) (0,0) to 654) (0) (Bye <) Aas > (a) (30,20) od (40, 28) me ged’. 26°22 = 4, 08-6! Aim 40-30 & 2 dy - de. - £-, aPplgeng the formes dp>D Lp: =o dp = lp 4 2ely- ade Cytt-4) eke Xl oy loz y [ dlecision parameter! clap +2ey: ae JO, 720 3l 2) Slee 2 a 22 2 a2 -2 Some ees le 14 34 23 Sano ral 10 38 | 24 35 | 24 6 36 | 25 ae | L | ; St | 26 34 | 26 =) ‘| . a + 36 | 26 | 38 | 26 14 i 34 2t ade 10 | : | Or 26 40 [2% 6 &) 0,0) bo ¢6,4) eed Oo 4 = Dee] Lr- 2 ioe 6 clp = Daly de? 24) -S ~ 3- aoa, oF th dp 20 lecise lene cecigi omnehers + 2oby -ddboe Cytl- y i i dpep:- oe oor oly . ade Cy) j 6 (¢) (oo) b (5,6) me GeO ee Ae ae 6 dp = 2de- ly = gls)-6 = 4. lying the Petr vlo ete cf aeons dp = dp + 2d. - 2oly Cat] Hn); 222+ [2> 1 ox ies oe do t2du-dy oe) mem at | clecishon poromehes oO l

You might also like