100% found this document useful (1 vote)
342 views93 pages

CG Decode

Computer Graphics Decode for Insem

Uploaded by

trishak2305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
342 views93 pages

CG Decode

Computer Graphics Decode for Insem

Uploaded by

trishak2305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 93
TABLE OF CONTENTS Chapter-1 Graphics Primitives (1-1) to (1-15) 4.1 _ Introduction 1-4 1.2. Persistence, Resolution and Aspect Ratio.. Ae 1.3. Frame Buffers: 1-5 1.4 Display Device sso Chapter-2 Introduction to OpenGL (2 - 1) to (2 - 19) 2.1 OpenGL Architecture. 2.2 Primitives and Attributes . 2.3 _ Simple Modelling and Rendering of 2D and 3D Geometric Objects 2-11 2.4 Interaction. 2-13 2.5 Picking... 2-16 Chapter-3 Scan Conversion (8 - 1) to (8 - 22) 3.1 Lines... vB 3.2 Line Drawing Algorithm: 3.3 Antialiasing and Antialiasing Techniques... 3.4 Circle Drawing Algorithms. ” Polygons and Polygon Filling (@ ~) q5 7 Chapter - 4 ‘44 Introduction t0 Polygon 42. Inside Test 43. Polygon Filling. ‘Windowing and Clipping Chapter -5 5.4 Introduction. 5.2. Viewing Transformations .. 53. 20 Clipping... 5.4 Cohen-Sutherland Line Clipping Algorithm, 55 Polygon Clipping. 5.6 Weller Atherton Polygon Clipping Algorithm, PA iae i Chapter - 6 2D Transformations (6-1) to (6-19) | 6.1 Introduction 62 Two-dimensional Transformations 63 Homogeneous Co-ordinates... 64 Composite Transformation 65 Reflection and Shear Transformations. Inverse Transformation. Chapter -7 66 3D Transformations and Projections (71) t9 (7-19) Tel 7A 3D Translation.., wi) 72 73 74 75 76 7 78 79 3D Scaling, 30 Rotation... Rotation about Arbitrary Axis, Concept of Parallel and Perspective Projections Types of Parallel Projection: Types of Perspective Projections 3D Viewing... View Volumes and General Projection Transformations. Chapter - 8 81 82 83 8.4 85 ‘Colour Models (8-1) to (8-8) Properties of Light. CIE Chromaticity Diagram RGB Colour Model HSV Colour Model CMY Colour Mode! Chapter -9 "Illumination Models and Shading Algorithms 9 9.2 93 94 95 (9-1) to (9-8) Light Sources 3 Ambient Ligh Diffuse Illumination and Reflectior Specular Reflection. Shading Algorithms Chapter 10 yo. troduction valgoit 12.6. Image Transformatio tion and Removal Algorithm... Raster Technique. 40.2 Back Face Detect 12.7 ique... z-buffer Algorithm.. fer-13 Ani 103 28 Chap! inimation (13 - 1) to (13 - 6) aoa Painter's (Depth Sort) Algorithm 105 Warnoc’s (rea Subdivision) Algorithm - - 43.2 Conventional and Computer Based Animation. Unit -V 13.3. Design for Animation Sequences 13.4 Animation Languages. 13.1. Introduction Cuvesand Fractals = (11 - 1) to @y Chapter - 11 +19 13.5. Keyframes and Morphing. 11.1 Curve Generation 13.6 Motion Sp 112. Interpolation ‘Chapter - (14 - 1) to (14 - 6) 11.3. Spline Representatio wd-1 14-5 114 Berier Curves. us 14.2. Advances in Gaming Eee _ Solved SPPU Question Papers 116 (S- 1) to (S - 16) 17 Chapter-12 Segment . (12-1) to (12-19) 12:1. Introduction Graphics Primitives =| 4. : Introduction Q.4 What is pixel ? pg>[SPPU : Dec.-09,11,13, May-13, Mark, Ans: In computer graphics, pictures or graphics objects ate pr n of discrete picture elements called pixels, the smallest addressable screen element, computer graphics 763°[SPPU : Dec.-14,19, Marks 2 # The computer graphics is one of the most effective ay commonly used way to communicate the processed information to ite S 2] Seite splays the information in the form of gray pictures, charts, graphs and diagrams in can say that computer graphics: makes it possibl pictorial form, objects. such ss le text. Thus we to express data in * The picture or graphies object may be an engineering drawing, business ‘Srephs, architectural structures, a single frame from an animated movie or @ machine parts illustrated for a service manual, 23 Why computer graphics is emerging as an important field in hee Science, SSISPPU : May-05, Dec.-07,08, Marks 4] Bs i Computer graphics permits _ extensi i i : fensive, high-bandwit niet interaction. “It significantly enhances the al jbiestand information, 10 perceive rend and to visualize moving or stationary in a realistic environment. It Set high quality and more precise results and lower analysis and design cost, Because of the i SE Teasons, com, st a ‘mportant fed in computer Seionge Pet Sraphics is emergining as ieere a-1 Computer Grophles be stored and manipulated NB IS necessary only to inp Plotting of Graphics and Chart and educational organizations, com used to create 2D and 3D. gr economic functions in form of business, government most commonly physical and Computer-aided Drafting and Design : Tae computeraided drafing uses graphics to design components and systems electrical, mechanical electro-mechanical and electronic devices such as automobile bodies, structures of building, airplane, ships, Very Large-Scale Integrated (VLSI) chips, optical systems and computer networks, Simulation and Animation : Use of graphics in simulation makes mathematic models and mechanical systems more realistic and easy to study. The interactive graphics supported by animation software proved ‘their use in production of animated movies and cartoons fiims. ‘Art and Commerce : There is a lot of development in the tools Provided by computer graphics. This allows user to create artistic Pictures which express messages and attract attentions. Such pictures are very useful in advertising, Process Control : Process systems and processing parameters are shown on the computer with graphie symbols and identifications. This makes it fasy for operator to monitor and control various processing parameters at a time, ; “Cartography Computer graphics is also used to represent seoshie Maps, weather maps, oceanographic charts, contour maps, Pop' density maps and so on. ‘ Q "A Guide for Engineering Students 13 Graphics, a compte TBE Sh 3 to jing + C Ben ia and a alan mode ¢ piysial phy; eae i Sg mar syste POPU ertand the operation of the system, ‘can help train s used to emage Preesitt on the other hands, applies "echaiga jctures. Image ‘nd ay or iter exis seam inages jagram explain raster sean display “ah the belp of block diagram plays, 5 el; Dec-08,0,1345, May-08/1014,18, Marks g i Fie Q51 shows the architecture of @ raster display, :. seolay controller, Central Processing Unit (CPU), vig, i sons of a, ejoards mouse and te CRT. : sass inthe Fig, Q5.1, the display image is stored in the fom g 5 and Os in the reftesh buffer. = td WO part fod (iteration dat) (Display commands) | 4 Display corre | (ecoocamaaRTTOR Bsessassoseseaeaso00g Boa0dcooadasaeosboed Reteshouter Fi 9. Q5.1 Architecture of a raster di play A Guide for Engineering Sule Computer Grophies, ba Graphics Primitves fesh buffer and produces the actual is by scanning one scan line at a time, and then back to the top, as shown in the in is the most common method of displaying images on the generated to move the beam al over the screen in a pattern shown in the Fig. Q. ‘Here, the beam swept back and forth from the left to ‘the right across the sereen. fed from the is ON. The Fig. Q5.2 Raster scan CRT is moved from the right to the left as shown by dotted line in Fig. Q5.2. ‘© When the beam reaches the bottom of the screen, rapidly retraced back to the top left to start again. A display produced in this way is called raster scan display. Q6 Define random sean display. ca [SPPU : May-14, Marks 2] Ans. In displays where the beam is moved between the end points of the graphics primitives is called random (vector) scan displays. 1.2 : Persistence, Resolution and Aspect Ratio Q7 Define following terms : 1) Persistence [@P[SPPU : May-14, Mark 1] 4i) Resolution ii) Aspect ratio Ua [SPPU : Dec.-06,10,13,14,15, May-09,15,19, Marks 4] OR Write the properties of video display devices. 1 [SPPU : May-15, Marks 4] ———— aay “Tarn Stes 1-5 Persistence is defined as the time een to decay to one-tenth of lution : Resolution es iisplayed without overlap oP Sf points per centimeter thy i i aio: It is the ratio of vertical points to horizontal pon Aspect al length lines in both directions on the screen, Hs ty produce © 1.3 : Frame Buffers Q.8 Define the following term : Frame buffer. 1[SPPU : Doc.-11,12,15, May-13, Marks 2) cribe frame buffer display in computer graphics. [GF[SPPU : Dec.-13, 16, May-15, Marks 4] ‘Ans. + In raster scan displays a special area of memory is dedicated to ‘paphics only. This memory area is called frame buffer. It holds the set of intensity values for all the screen points. OR Desi oetey erste SBROAE Fig. a8, ‘9: 0.8.4 A 24-bit plane colour frame buffer ‘A Guide for Enginecring Sten Computer Graphles 16 Se Graph The video controller retrieves fer and displays them on th he stored intensity v fro screen one row (scan frame ie) at a time, Plane colour frame buffer. In 24-bit plane. he 0h colour and ence thee are planes : it planes drives an #-bit DAC. Each enerates 256 shades or ii a generates 256 (2") shades or intensities of red, green or blue, These ae full colour frame buffer. = Q.9 Find the refresh rate of a 512 x 512 frame buffer, if the access time for each pixel is 200 nanoseconds. [F[SPPU : Dac.-10, Marks 4] Ans. ¢ Refresh rate = Access Umne for each pixel Number of pals information in Fame Butter 1 Socio SLRS = ert a ae, @Q.10 Find the amount of memory required by an 8 plane frame buffer each of red, green, blue having resolution of 1024 x 768. CaP[SPPU : Dec.-12, Marks 4] Ans. : For 8 plane frame buffer cach of red, green and blue requires 24-bits to represent per pixel. Amount of memory required = 24 x 1024 x 768 = 18874368 bits = 2359296 bytes 1.4.: Display Devices Q.11 With a neat cross scetional view explain the functioning of CRT. Ans, : © A CRT is an evacuated glass tube. An electron gun at the rear f the tube produces a beam of electrons which is directed sowares te front of the tube (screen) by- a high voltage typically Tr Gunde for Engincering Stents charged electrons are then acceler ce negative Corer side of the screen by @ high rs ing anode. The phosphor substance Of the cathode-ray-tube consists of two pairs of poe see ferred to as the vertical and horizontal deflection ced by electrons: ‘ s sok the phosphor glowing is to redraw the tron beam and voltage appl Shay irecting fy corurbat Dk ov ontrols the horizontal deflection of the electron beam. called a ref . fe determines the velocity achi the phosphor. The control gi ‘are actually in the electron bear, List the methods used for colour display. ere are two basic techniques used for producing colour through. Since the aniount hosphor depends on the number sc we contol the brightness of a display by Explain the beam - penetration technique. : This technique is. used with random-scan monitors. In this ‘of red phosphor and inner layer is of green phosphor. A beam of slow lecrons excites only the outer red layer. A beam of very fast electrons enetrates through the red layer and exeites the inner green layer. At , combinations of red and green light are emitted tage controls the speed of the electrons and hence the colour at any point on the screen. and Demerits fan inexpensive technique to produce colour in random scan It can display only four colours. Hononia detection latos Fig Q114 Cathode ray tubo — “A Gulde for Engineering Suadewss A Gulée for Engineering Sus? |, se ahadow mask Graphics Primtives ask esgue a0 ePIBIN DOW doggy do technique ? Storage Tube (DVST) uses the storage grid which ‘mation as a charge distribution just behind the charge. The knocked out electrons The net positive charge on the lure pattem. The continuous low speed ugh the control grid and are attracted the positive charged areas of the storage grid. The low speed Jectrons then penetrate the storage grid and strike the phosphor coating without affecting the positive charge pattem on the storage grid. During this process the collector just behind the storage grid smooths out the flow of flood electrons, Selection of shadow mask ‘Magnified Flood electrons phosphor-dot Focusing and triangle deflection system /] Fig. 0.14.4 The shadow mask grid consists of se Phosphor dot pattem. As shown in the , three electron beams ae deflected and focused as a group ont dow mask and when on bass through a hole in the shadow mask, they excite a dot. triangle. ot tangle consists of tee small phosphor dots of red, green and These phosphor dots are arranged so that each electron ial PS conesponding colour dot when it passs on ‘ot triangle when activated’ appears a5 9 | das acy S80 Mish hs clo of combaton of ree mal | Fig. 0.18.4 Arrangement of the DVST beans we can obuin ae) Vat the intensity of the three electron diferent colours in the shadow mask CRT. eons ‘Engincering Stents Gite for Enginerng Sue GROSS oe of holes aligned with the er Graph Le pts it torage Tube (DVST) uses the storage gid which formation a5 a charge distibution just behind the iows the general arangement of the DVST. It consists 4 primary gun and a flood gun. A primary gun pattern flood tains the picture igh speed electrons which strike on AAs electron beam strikes on it knocks out electrons from the charge. The knocked out electrons The net positive charge on the ectron gus, rT. It has three ¢! coated screen. or rid just being the phosphor Elector to the positive charged areas of the storage grid. The low speed Jeewons then penettte the storge grid end stike the phosphor coating Saihout effecting the postive charge pater on the storage grid. During " Fris_process the collector just behind the storage grid smooths out the flow of flood electrons, ours and are available with sin removal of charge on the storage gy i process takes several seconds, screen is not possible, so ee (pom — OTE cof screen produces unpleasant flash over the en eee Ese 4 nt preven i se of amie eaphies ap gf a a result of the comparay 4 5, It has poor contrast 3 | ‘eupan seceerating potential applied to the flood electrons, ote 6 The pefrmane of DVST i Some what inferior to eoreniowoiet | ange cat. 2.17 State the rypes of flat panel displays. Fig. 0.18.1 Construction of plasma panel display State the advantages and disadvantages of plasma display. Ast There are two types of fat panel displays : emissive dis advaiaied displays, ean eee convert electrical energy into light ell |. Refreshing is not required. lays : They {nto light energy i Plasma panels, thin‘film electro luminescent displays, and light . Produces a very steady image, totally free of flicker. . Less bulky than a CRT. are examples of emissive displays, 1. Allows sclective writing and selective erasing, at speed of about 20 see per cell. 5, It has the flat screen and is transparent, so the displayed image can be superimposed with pictures from slides or other media projected through the rear panel isadvantages Strictly monochromatic devices. 2. Relatively poor resolution of about 60 dots per inch. — “A Gude for Engincering Students missive displays : They use optical effects to convert s light fiom some other source into graphics pattems. Li display isan example of nonemissive fat panel display. 148 List the operating characteristics of plasma panel. ; 5 [JNTU : May-07, 08, Sept.-08, Mai Ams: + Fi QU61 shows the consmction of plasma panel di The gad exe Lutes of aus with thin closely spaced gold elect g0it electrodes are atached 10 the inner faces and covered ont A Guide for Engineering the CRT. petwcen lila electra i at refers to the fact that these gop, mol n ematic (tread lke) gg’ iN here scm eng et of te 20d shaped 4 ae . alt ing 2 light polarizer at right ater ae Sons ae uit into one BI68S plate, and colyyy | kos sve put into the oter pat. The intersection gf er dalnes pixel postin. In the ON state, polarize jy? ‘conductors posing troagh material is twisted so that ‘opposite polarizer. reflected back to the viewer. To tur OF the pixel, we apply 2 the molecules so that the light is not twisted as shown ig Fin Q21, This ype of flat panel device is referred to as a pas nx LCD. Inactive matrix LCD, transistors are used at each (yy cause the crystal to change their st | the degree t0 which the state hes tex woperies allow LCDs to be used in miniawe ee 4s changed. Thus use of transistt i ving brighter dis it it it had to be refreshed peri cally, wighter display than it would be rg A Guide for Engineering Suet lecules, yet they flow like Ars Ni Graphics Prinitves Posariter Polarane ‘Transparent Polarizer ‘conductor ‘OFF State (b) Flold effect display ‘OFF State’ Fig. O.2141 ‘Advantages of LCD Displays # Low cost « Low weight ‘+ Small size «Low power consumption Q.22 What are LED displays ? ¥ ‘Ans. : @ The Light-Emining Diode (LED) displays are emissive type display. In these displays, a matrix of diodes is arranged to form the pixel Positions in the display, and picture definition is stored in a refresh buler Se cons “A Gude for Engineering Sade ‘a, information is read fo is that are applied green displays are : ‘Many institutes US° large screen display Mul traning in the cless-room. YS to & Large sereen displays are used 10 ya if or in the community halls, eh jy ove gaomse Lege eC a used t0 show o, = a Bes inthe tio. ; my “Advertisement + Large sereet. displays are used for adver, many public places. ny wy and roadway transport = Large screen di railway stations, airports and bus sain ule information to the travelers. * po 4. Seminars, presetatons and video-conferencing = Large sing, plays are used during presentations, seminars video-conferencing. 1. Space stations: Lae screen displays are used in space stating to display the satellite images of the planets. They are used as ne of the visual communication medium for communicating wig the astronauts. Plasma-pael and fet panel displays support large screen displays. END. => ‘A Guide for Engineering Suseo® Unit 1 ) Introduction to OpenGL 2.1; OpenGL Architecture 4s openGL ? © [SPPU : Doc17, Marks 3] OpenGL (Open Graphics Library) cross-language, Programming Interface (API) for rendering 2D cally used to interact with a Graphics Processing Unit fe hardware-accelerated rendering. ‘gaphics primitives, attributes, transformations and many other OpenGL is designed to be hardware independent, therefore many ‘such as input and ouput routines, are not included in the asic library. However, input and output routines and many additional functions are available in auxiliary libraries that have been developed for OpenGL programs. 22 State the naming conventions of openGL. ‘Ans. : © Function names in the OpenGL basic library (also called the OpenGL core library) are prefixed with gl and each component word within @ fiction name has its first lewer capitalized. The following examples illustrate this naming convention. ‘giBegin, glClear, glCopyPixels, glPolygonMode ‘Some functions in OpenGl require that one (or more) of their arguments be assigned 2 symbolic constant specifying, for instance, a parameter name, a value for a parameter or a particular mode. All such constants begin with the uppercase letters GL. In addition, component words within’ a constant name are written in capital letters and the underscore (C) is used as a separator between all component words in the name. ae er a-n ‘operations, 22 Introductin mn to amples ofthe several hundred sym. fe Open: futons. wih Open a Introduction ts Open Video screen Display window rail for a at RGR, oboe GL_POL’ G2 ST AND_DFFUSE GL_AMBIENT’ say window ma ment using GLUT, ‘03 Explain the displ serfrm te © (argc argv) carat 2 display window is 10 BE Tete on cas Spon fr the se bat. Tis 1 aecomplishe ‘st with i finer rresteWindo (An Example OpenGL Program’ ae ned o speci what the display window isto TT ern a pine sing OpenGL fntions and pass th defnition to the GLUT routine glutDisplayFunc, which assi picture to the display window. . Je, suppose we have the OpenGL code for describ fe ore te in Blo LUT iniaization with the statemen, 12.3.4 A 300 by 200 display window at position (50, 60) relative t Fi the toptat cotter of tw laa Gapny™ “s We can also set 2 number of other options for the display window, such as buffering and a choice of color modes, with the glutInitDisplayMode function, Arguments for this routine are assigned symbolic GLUT constants. or example, glutlnitDisplayMode (GLUT_SINGLE | GLUT_RGB); ‘The above command specifies that a single reffesh buffer is to be used ‘the display window and that the RGB (red, green, blue) color mode to be used for selecting color values. Q4 Give the format of OpenGL command. ‘Ans. : The Fig. Q.4.1 shows the format of OpenGL command. giVertex 2 K of Basic _Numberof Type of library command arguments argument Fig. Q.4.1 Format of OpenGL command QS Explain the vertex function in OpenGL. “Ans, : © In OpenGL, the general syntax for vertex function is givertex * () where the * can be interpreted as either two or three characters of the form nt or mty, where —— A Gude for Engineering Stents is not yet on the screen. We need ete the window-processing operations, «This fonction must be the last one in the program. ‘graphics end puts the program info an infinite loop that checks for for devices such a8 a mouse or keyboard, 2 ‘+ We use the glutlaitWindowPosition function to give an initial locaton forthe top left comer ofthe display window, z i ‘lutinitWindowsize (300, 200); ¥ “Afi the display window js _ e it ay {8 on the screen, we can reposition and 1" = ‘A Guide for Engineering S08 cong COPE. The of 5 pets dl PE o js integer at od: double . ified 2 ries ate voles ae specie Trough gy «AS er than cough a argument Tit to on ay, jimensions (2, 3 oF 4) 3 rystem can contain ions are divided into seven, tex function in OpenGL, a of ve 6 State various forms ‘ eee q 7 grerexti GLint Gtint y) + Function works 6 $4 tension with integes- i ty, GLfloat 2) : Function works i giertexst (GLfloat x poe re = in thee | + These functions define the low-level objects or dimension with floating poi 4 | stom ets hat our este, an ply, Depng on te AP he + Funct in three dimension with float es can include points, line se ls, glvertex3tv (vertex) + Function works in with floating Mees of curves and ste pelea ie eam point numbers. Attribute functions : These functions allow us to perform operations fanging from choosing the color with which we display a line segment, jcking pattem with which to fill the inside of a polygon, 10 ‘a7 State the data types supported by OpenGL selecting a typeface for the titles on a graph. “an Table Q.7.1 shows the datatypes supported by OpenGL. a rr C Type OpenGL Tyg]| « Viewing functions : These functions allow us to specify various views, Suffix | Data type us pen Tye | Uithough APIs differ in the degree of flexibility they provide in choosing & signed char GLbye || view. : short Glan ]| Transformation funetions : These functions alow us fo cay out transformations of objects, such as rotation, translation! and scaling, i int or long GLint, GLsizei |) Providing the user with a set of transformation functions is one of the 7 te Guna, Gia || _ carecteities of good APL 7 tions : These functions allow us to deal with the diverse nia GLdouble, forms of input that characterize modem graphics systems. These GLelampd " fanetions include the functions to deal with devices such as keyboards, we | sti uns nig Ga Gi ~ mice and data tablets, ae ‘Control functions : These functions enable us to communicate with the ws] bit uns window system, to initialize our programs and to deal with any errors iebiwoteat | taped ton that take place during the execution of our programs. cae Query functions : Within our applications we can often use ober Soi amione unsigned in information within the APL, including camera parameters or values in = GLbitfield the ffame buffer. A good API provides this information through 2 set of Nothing sai cin + query functions. Table Q7.4 OpenGL a bccn — ‘A Guide for Engineering Students Guide for Engineering ce 2 GL_POINTS imitive to draw a sequence of connected line segments, 2 rR E> LA okt 4! POLYGON pL Gt_LINE_LOO} alVertex2i(x3, y3); ants giEndd): 4 7 )peNGL primitive types GL_POINTS * We use this primitive type to render mathematical points. + Example: aBecinat, Ponts, alVerexziet, yi) glEnd(); z : eS SS A Guide for Engineering SH" GuceeS “A Gale for Ergnering Sader a ie ong oy mice of triangles \ s RIANcle! OF ge ns ri to draw a sequel We ws cou TRIANGLE_FAN a We use this primitive daw a fan of triangles that share guy : ies slg share a verte Bach ti 4 angle shares the fist vertex specitieg «Example + jegin(GL, TRIANGLE_FAN): aivonexct, yi lvortendix2, glvertex2fix3, ¥3) glVortexdttx4, ¥4); clad); GL_QUADS «We use this primitive to draw individual convex quadrilaterals o Exa giBegin(GL_QUADS); alVertexzi(e, y1) lVertax2(x2, 2) alVertex2ie3, 8); glVertex2iix4, y4); glEnd(); GL_QUAD_STRIP We in edges ‘his primitive to daw a sequence of quactilaerals tat $* = “A Guide for Enginee™? anputet Gaphes - Introhacton ts pent glBnd; Gt_POLYGON ‘We use GL_POLYGON to draw a single ‘OpenGL renders un id by the ap ‘giBogin(GL_POLYGON); glVortoxattet, v2) aiVertexatte, ¥ glVertex24(x3, yi glVertox2ited, v4 giVortoxattes,¥ giEnd); Q.10 List OpenGL point attributes, ‘Besides changing the color of a point, we can also specify the We set the size for an OpenGL point with ‘iPointSize (size); ‘eParameter size is assigned a positive floating point value, which is rounded to an integer (unless the point is to be anti-aliased). A point ize of 10 (the default value) displays a single piel end = point sie of 2.0 displays a 2 by 2 pixel amay. Q.41 List OpenGL line attributes. ‘Aus. « Line width : It can be changed using te fllowing, OpenGL function slbineWidth (width); “We assign a floating-point value to parameter rounded to the nearest non-negative integer. ———— A efor Egincerig Ste width and this value is 24 We have (0 methods for displaying characters with the OpenGL. Bither we can design a fort set using the bitmap functions in the core library of We can invoke the GLUT character-geoeration routines The GLUT library contains functions for displaying predefined bitmap and stroke er sets. Ther character attributes we can set ite those that apply to either bitmaps oF kine segment itmap or outline fonts, the dlsplay color is determined by the state i spacing and size of charhcters is determined by the font ‘Rejgnatin, such a GLUT BITMAP § BY 15 and GLUT STROKE MONO ROMAN. However, we can also set the line width and line type for the outline fonts. ‘We specify the width for a line with the giLineWidth fimction and we Ject @ line type with the gllineStipple function. The GLUT stoke fonts will then be displayed using the current values we specified for the OpenGL line-width and line-type attributes. Te epeatFactor specifies How many times eagh 5 vege perme Pod before the next bitin the pate ial pa repeat Nae 5 T f tp displayed in the current Hine-style pattern, ye f ig feature of OpenGL. We accomplish this wie jeu (GL_LINE_STIPPLE); Wea ecebling this feature, lines would still appear as solid ‘even though 2 pattern was provided. the use of 2 pattem we can issue the following 2.3 : Simple Modelling and Rendering of 2D and 3D Geometric Objects iDisebe (GL, LINE, STIPPLE): 242 List OpenGL fill attributes. ‘Ans: « By default, a polygon is displayed as a solid-color region, 0.14 Write a short note on modelling and rendering, ‘Ans. : « Two principal tasks are required to create an image of a two or the cunt color sting. 12 i aI dimensional : Modeling and renderir To fill the : 3 .e-dimensional scene : fering. andes tc fae eee ee 12 modeling task generates t node, which is the description of an e-style object that is going to be used by the graphics system. Models must be created for every object in a scene; they should accurately capture the geometric shape and appearance of the object. «The 1d task, rendering, takes models as input and generates pixel values for the final image. . 7 “OpenGL supports a handfull of primitive types for modeling two-dimensional (2D) and three-dimensional (3D) objects : Points, lines, triangles, quadrilaterals and (convex) polygons. ane ‘Patter [] = { Oxff, 0x00, Oxtf, 0x00, ...}; Quis we Have St he mask, we can establish it as the cure: si here ar (pattem); * We need to enable the fill roti i ces Me es before we specify the vertices ie ey HY Be led with the euzrent patra, We do Enable (QL POLYGON. srippLpy, —— ‘Ceonss “A Gale for Engineering Stents “A Gude for Engineering St 2, A keyboard callback function. It receives key that was pressed and the current x aad argue mouse. ion registered by glu The callback function regist slutKeyboarar, anly keys comesponding to ASCII graphic characters ana, 0 3 and delete, The keyboard callback function in Fig. Qig default Keyboard function Tt allows the user to quit th ie pressing the escape key. #define ESCAPE 27 void keyboard (unsigned char key, int x, int y) { Lf ey == ESCAPE) keys: glutSpecialFune(special); 2. Declare the special key function as follows : Quitting with the escape key respond to other Keys, such as the arrow cial key callback function. som Introduction to Open@he vold special (int key, tat x, int ” . . switch (key) { case GLUT KEY Fs: 1/ code to hale Ft koy break: 0Ordinates or et + } ‘eThe arguments 'penGL passes to special() are: The defined in Table the X co-ordinate of the mouse cad ae co-ordinate of the .19 Explain the mouse event callback function. “e glutMouseFunc(mouse_button) 2, The mouse callback function is passed four arguments. | | Table 0.18, * O48 Constants for special keys | es ‘4 Guide for Engineering Students GLUT-KEY FI | GLUT_KEY_F8 GLUT_KEY_UP The first argument specifies the button. Its value is one of _ « GLUT_LEFT_BUTION, GLUT_KEYF2 | GLUT_KEY_F9 GLUT_KEY_DOWN » GLUT_MIDDLE BUTTON, or a GLUT_KEY_F10 GLUT_KEY_PAGE_UP * GLUT_RIGHT.BUTTON i value is one of GLUT_KEY_F4 * The second argument specifies the button state. Its vs — a GLUT KEY_PAGE DOWN, + GLUT_DOWN (the button has been pressed) or Gurxevs | aurxeve | our KEY HOME + GLUT_UP (the button has been released). Sorxerrs | curxevuet | cuoresy ep ©The remaining two arguments are the X and Y co-ordinates of the ese mouse. ou TREY RIGHT | GLUT KEY INSERT 220 Write a note on window event. Ams. @ Most window systems allow a user to resize the window interactively, usually by using the mouse to drag a comer of the window ‘02 new location. mii 2a eps Involved in pleking process wh used, back batter . calbeck Function 7 oi ohape(oLse w, size) gr scene info the fame bu ‘ifthe scene. However, once eae in seleon mods te eons + change uatl we exit selection mode, ‘We we thse vas 19 create a-new OpenGL clipping window using leritD, x wel we ew vipat wi the same aspect ratio. | oe constet the mame stack by lading names ono 8S Ut ving commands while in selon mode. Ths, wien the etumaed, we ean use it to determine which primitives selected on the screen by the user. “fin sion to this selection mode, OpenGL. provides @ uiliy routine to simplify selection in some cases by restricting drawing to & Jon of the viewport. Typeally, we we this routine ro determine ects are drawn near the cursor, so tat we can identify which ct the user is picking. i act og 20 vlan compute Fm Bet Cha 8 song nd ee A Gale for Engicerng Sud bly want to save and then restore the sate with glPushMatrixd) ang drawing commands and commands tp mani fack so that each primitive of interest hay an appropriate name assigned. . Exit seleeon mode and process the retuned selection (de bit records). "0.25 How to use selection mode Ams + 6 We can use selection To do this, we use a special 7 projection matix to restrict drawing to a small region of the viewport, typically near the cursor. ‘©Then we allow some form of input, such as clicking a mouse button, t initiate selection mode. ing ing we are typically determining which objects are drawn «Picking is set up almost exactly like is, wit Pilon as xsly lk regular selection mode i, withthe A Guide for Engineering Students END... “A Gale for Engines | unie | version [ese] ad line aa no curves, n0 thickness and line segteat (02 Defize vectors. Fe{SPPU : Doo.-07,11, Marks 2] Tans A eco is a eaty basing ection as well as magainds, Spey as deerig te positon of one point in space relative to | sib. a3 What i vector generation ? Explain the problem of vec seuertion. 1 [SPPU : Dec.-12, Marks ‘Ans: The process of turing onthe pixels fora line segment is ealled jecfor generation or lize generation and the algorithms for them ae Inova as vecor generation algorithms or line drawing algorithms. Problems of vector generatior The 45° ine is sah but is ‘width, Such cases are due to the finite res ion of display and we [Hive to accept approximate pines in such sitions. (SPU ; Dec.-07,11, Marks 2) ve I it does have ends it i called @ [SPPU : May-05, 10, 11, Anse Sean Comeron Ser eon ‘ using simple integer arithmetic + Imple hardware or firmware ‘a4 Explain DD) 1m for line. Discuss its advantages and aisadvantages- 11, 19, Dac.-06,07,08, Marks 10] DDA Line Algorithm 4. Read the line end points (x, 7;) and (ty) such that they are not equal [ if equal then plot that point and exit] 2 ac 3 [xq ~1) ‘and Ay =|¥2 -¥i 3, if (ix24y) then ongth = dx [This 4g either| x) =x |0r|¥2 {noremental value for eit 6. x= x, + 05 © Sign (4) yy, +05* Sign (87) ako the yi} Therefere, the ‘xory is one] algorithm work in all Here, Sign function quadrant, it gerums ~ 1, 0, 1 depending on whether its 0, > 0 respectively. The factor 0.6 makes <= “found the values in the integer function rather The bigness F than truncating them ae rae the line is dependent on the orientation of the line. ‘plot (Integer (x), Integer (y)) 1+ We can observe tht the effetive spacing between pixels for the 6 ial is geater for the 45? 1 | few eal ‘etal and hrtontl lines, Th ee {Bogie the loop, in this loop points are plotted lines appear brighter than the While (i slength) : { “ = Ti Bg Computer Graphles 33 Seon Convey an ai an iii xaxt ax ? =ytay x Jiot (integer (x Integer (y) init } 7. Stop Advantages of DDA Algorithm the simplest algorithm plementation. | . hod for calculating pixel positions than the dire ‘= mx + b. It eliminates the multiplication in thy ‘ty making use of raster characteristics, so tha se increments are applied in the x or y direction to fing ‘sions along the line path. ad it does not require special sky Disadvantages of DDA Algorithm 1. Foeng poit aithmeic in DDA algorithm is’ si Eeecousming. ‘2 Tee algoctim is orientition dependent. Hence end point ; is por. sooumey JOS Consider the line from (0, 0) to (~ 6, ~ 6). Use the simple DDA algorithm to rasterize this line. f [SPPU : June-12, May-17, Marks 10] ‘Amt : Eraizting sips | to 5 in the DDA algorithm we have, %=0 nao %=-6 ne-6 Legh = |x2-n|=|y2-y)[=6 = yeni Initial values for x= 0+05*Sin(-1) =-05 ¥ = 0405+ Sign (1) =-05 =——_____ A Gulde for Engineering Suidents ‘The results are plotted as shown in the Fig, Q..1. It show rasterized line Hes on the actual ine and itis #8 See = 35 3 2 BD) (2) ve pixel values are Fig. meh ye Length = bea-% en with relerence to pixel atthe center of screen Q.5.1 Result for a simple DDA Using DDA algorithm find out which pixels would be turned on the line with end points (1, 1) to (6, 3). [@ [SPPU : May-15, Marks 4] 1, xy =5y2"3 S124 “A Guide for Engineering Students Computer Graghles Ax = [xz —x;|/ length = Ay = Iya -yi//length = Initial value for 7 Consider line segment from A(-2,-1) to B(6, 3) use DDA line drawing algorithm to rasterize this line. c= [SPPU : May-19, Marks 6) ‘Ans. : Evalusting steps 1 10 5 in the DDA algorithm we have, ny = -2yj eden 76 and y2 3 = (6-2) =B- plor(3, 1) ‘A Gulde for Engineering Sments - Q9 Explain Bresenham's line drawing algorithm. E@ISPPU : Dec.07,12,17,18, May-14,15,17,19, Marks 3) ‘Ans. : Bresenbam's line drawing algorithms for 0 ay=[4-21= ° repping along the Tine we ha Aus. ¢ 2242-3=1 c stePl jen the boundaries we to tum on all the ea 2eayAX=: betwe S: Ths is itustrated in Fig QU “ESE He e x y Plot T = i 3 2 62 ; 1 6 3 6,3) ES 2 ; 7 3 3) Xe) 1 8 4 @4) (=) 3), 7, 3), (8, 4). ‘be tumed on for the line : (5, 2). (6 Pixels would 1 Consider a ine from Cs 6) (8, 8). Use Bresenham's line ot ng agoritb raterize this ine Car [SPPU Dec.-19, Marks 6] gh step 4 in the Bresenham’s algorithm we on Petewrdanes ‘Ans. + Evaluating step 1 th have, axe B-212 6 dy= 18-5173 Fig. Q.18.1 Thick line xenyrs Bi e = 2edy-Ax= 203-670 rebulating the result of each iteration in the step 5 through 10 sexet us consider line from point (xy, ¥4) ¥0 (33) havin items we tis oO Let sy Yi) 10 (Xy Ya) having , | hen we have a top boundary between the points (xj, y, + W,) and 2 [ae ie. a x Flot y, + Wy) and a lower boundary between 1 — %) and 1 @ 2 3 @5 Ya — Wy) Where wy is given by 2 =6 3 6 GO wey [62-1 +02-9" yw, - oy as oe LE 3 0 4 6 GO re Tel 4 Es 5 7 GD 4 Here, w, isthe amount by which 5 0 é 7 ea the boindary lines are moved 6 from the line cer as shown Es z s [as | 7 o —— 8 8 [eo | equation exist because the line boundary itself has a thickness of one pixel. We further divide the factor (w ~ 1) by 2 because half the thickness will be used yg, @.48.2 Thick line detals FG for Enginering Suen Qn Explain how DDA line algorithm can be extended to generate a oe oe Marks 8) a (Siero man ine, we have to run two line drawing. igorithms in parallel the pixels along the line edges, and while ot A Guide for Engineering Students Scan Conversion Computer Graphles to offeet the top boundary, ‘boundary. + We can use equal sharp slope lines, .e- similarly with the x 22 and the other half 10 Move the boy fog ry for lines having slope less than 1, iy roles reversed. In this C456 Wy (way [or +021 Fy any [oor tad boundaries are (%} +,» Ya) Fespectively- © Thus, left and right (m+ w+) 10 ‘Ans, : 6 In the line dravit focations do not match with the optimum raster locations to represent a straight line. This problem Severe in low resolution sereens. In such screens line appears like Stairstep, as shown in the Fig. Q.19.1. This effect is known as aliasing. e and we have to select a Fie: lasing offéct | 17148 dominant for ies having gentle and sharp slopes ‘* The aliasing effect can be red epFa along the ln, The proces of al the line to minimize the effect of, A Gulte for Engineering Students vs having slope greater than I ines are handjey ique of resolution and sampling’ ob called supersampling or port Sone Area sampling or Prefiltering ; 2s tana aca seed Oy seg ne tainty met si ialiasir tir aie js referred to as area sampling or prefieing 1 camps orci are ‘Antialiasing methods are further classified as shown in the Fig, Q20.1 me a Aare. o orgs wes Fig. Q.20.1 Classification of antialiasing methods unweighted Area Sampling ein this antialiasing, instead of picking closest pixel, both pixels are highlighted. However, their intensity values may differ. ‘+n unweighted area sampling, the intensity of pixel is proportional to the amount of line area occupied by the pixel. # This technique produces noticeably better results than does setting pixels ther to full intensity or to zero intensity. ighted Area. Sampling ‘In weighted area sampling equal areas conti area closer to the pixel center has greater greater distance. Thus, in weighted area pixel is dependent on the line area occupit from the pixel's center. “A Gude for Engineering Students Scan Conver, sas Computer Grapes —_— Prin 3a: cirele Drawing Algorithms va vector generation DA algorithm for circle, Q.21 Explain veetor gem TaTSPPO : May-08, Mar ‘Ans. : Algorithm 1, Read the radius 2, sat x0 say =t 3. x = sux yn sey (0, ofthe circle and ealeulate value of ¢ 4. ¢ (Rea tey yew7 8 [xy represents Sy and represents ] Plot (int (3) nt (¥2)) italize the current point ] } while (yy - stay) € [check iff the current point is the starting point or not. If ‘current point is not starting point repeat step 4; : otherwise stop] 5. Stop. Q22 Derive the expression for decision parameter used in Bresenbam's circle algorithm. Also explain the Bresenham's circle algorithm. FSISPPU : May-06,07,13,14,16, Dac.-07,12,13, Marks 10 Ams « Let us assume point P (x,,y5) is ee Now We have two options either t0 choose Pi oi ose Pixel amongst these two can be determined as follows (2 A Guide for Engineering Students Fig. 0.22.4 Scan conversion with Bresenham's a ‘e-The distances Of pixels A and B ftom the ofigin ae given as Dp = ¥ Gin)? +05 -17 Now, the distances of pixels A and B from the true circle are given s 5 = Dy-rand 83=Dg-1 ‘However, to avoid square root term in derivation of decision ‘variable, i.e to simplify the computation and to make algorithm more efficient the §, and. 8p are defined as & = De-F and 83 = De-? ‘That is by = Ott tye-2? ) by = G42 4Gi-D8 - 7 =) This function D provides « relative measurement ofthe sees the centre of a pixel to the true circle. Since Da will always “A Guide for Engineering Students Scan Converion Computer Graphics aad Dp will always be negative reste dy ean be defined ag = (A is outside of the true circle) © inside of the true circle), a deris d; = 84 +58 From equations (1), (2) and dy = Ge DP +t gy we have OP a(t DP ODE? 2a? seqenPeye toned : ees ‘< [85] and pixel A is chosen, Whey When dj < ee Sisel Bis selected, In other words i; 2 0, we bave |éy aa write, ne 2 at land :. Forge 0 Me getand wert ol 2 Ford 20, Mot 1) wn of Decision Variable (2+ Derivation of Fi os 3 (ye WP - 2044 DP -¥F 1 -P rt Weave, ; 4. = djo2(q +14? +97, 1 ¢ Vie 17D =26 21)? -yP = + 20R 44549497, + Ye 1 2Vie tT -2 (x9 +2x)+1)-y} -(yP-2yi + D = di + 2x} +8x;+8+2 92, .-2yi4d + 1-237 -4x;-2-y?-y? #2y;-1 = dir 4x;+2(y?, .-y2)-2(y;4 1-yi) + 6 IFA is chosen pixel (meaning that the.d; < 0) then ys, = y; and ia Gig 5 di * 494+6. On the other hand, if B is the chosen pi (cncaning thatthe d; 2 0) then ys. = yi —1and so Pa der = 4+49;+2[9,-02-y?]-2fy, -1-y,]46 = di +44 +20? ay, 41-y? 26146 = #45 ~491426246 wd, 44 yi)+ 10 58. for dy at sarin ai arting point Le. at x = 0 and y =r a) = 5, + bp +P +P -2 5 uy,+ 7 OF + OF -P +04 Rega? mtn P Let tee1 Pasar 23 Write and explain Brewshan'scucte drawing alot ih fainted mathema avis ‘ans. + Bresenham's circle dra | [SPU : Dec.-17, May-12, Marks 6} 1 algorithm to plot 1/8 of the circle + Read tho radius (1) of the ciscle a=3-21 [Initialize the decision veriabie] x=Oya8 [Initialize starting point] do { plot (% 9) if(4 <0) then { dat ants } else {d=d+4(x-y) +10 =y-1 y xextl } while (x < y) “A Guid for Engineering Students ‘A Guide for Engineering Stu: gorithm, a baer? Decision params fo select ‘correct pixel In clrcla generat rig, 0244 1 deo er(-9] “4 The incremeotal calculation can be desision parameters We can obtain a recursive expression for the next decision parameter bj cena circle function a sampling postion ext. determined to obtain the successin) ” positive, Yer = Yin ‘ doy = 4420+ 141-25. * she tenns 2x; , 1 and - 2y,. , in "te ee 1 i equations (3) and (4) can be dyes = 2442 Aye = MA? ‘The initial value of decision parameter can be obtained by evahting function at the start position (x,y) = (0,1). eile 2 a 4" tu »? (4) fe) ar? 2125-1 ‘Algorithm 4. Read the radius (r) of the circle 2, Initialize starting position as x=0 yer 3, Calculate initial value of decision parameter as P=125-r AG for Engineering Sue “A Guide for Engineering Stes 4. do { plot 6, 9) ia <0) {xexdi yey dedtartt } else xextl yeyot dads aetayel ) while (& < y) 8. Determine symmetry points 6, Stop. ‘the pire! position along the circle path with radia, rigin using Bresenham's circle drawing | to point x = y, d= 3-2re3-24 105-17 Tabulatng the results of step 4 we get x y a 0 10 =17 1 0 =u 2 10 =I 3 0 B 4 9 =5 $ g 7 6 8 UL L2 7 B A Guide for Engineering Suen ‘AGuleor Engineering St Sey rfspPU : Docw06, May42, Mark Gut What is polygoa ? Ans. : i.e, when polyline closed then 2 Is circle a paygon 2 Juste ar] SPPU : May-t1, Marks 4 ) ‘Ans 1 Ciele isnot 2 polygon, Because eile dont have any segments 0.3: Waat are diferent typeof polygons ? Explaia with example, 5[SPPU : Dec.09,18, May-10, 11, 12, Marks 4) ‘Ams, + There are vo types of polygons = + Convex and « Concave A coavex polygon isa polygon in which the line segment joining any "two poins within he polygon lies completely inside the polygon Fig, Q3 shows the examples of convex polygons. Fig, 3.4 Convex polygons Fig. 03.2 Concave polyeons an) mpster Grephles ———— r "9 433 Compne Polygon a pol ai i yone simple peliod of dOiN& Even “us 8 y onstuct @ fie ment oui paween the OO point in question int Bn to be ee A Fig. 44 solygon, as shove inthe Fi. 41, Now cmt ho en iteetins arte line segment with the polygon boundary occur. IF thee ae an Sia number of ‘intersections, then the point in question is inside, otherwise it is outside ‘pike intersection point vertex of the polyzon then we fate ook at ie other endpoints of the two segments which meet at ts vertex. IF these points lie on tbe sume side of the constucted Ine, then the ot in. question counts as an number of omg ott Fig. 042 “Gi for Engineering Sse cont wetworgon py Fon ccoues Fig. as acy eid eps ay fe ec mete east ot sec aa eg 8 Hee 0) weer 1 cnn oa feces: eh, pa oom apts Bont obit gon cso re alii to il page a gn th [SPPU : ay, Das, Mark 4 seins ged 0 ia aa ia 8 ses we car fil meas by alin be eon uy eee by ted region eve rie rso veri ad ot ‘of moves ia te 10 ‘Ans og ig aris a sd vn ag. Tie se fl ae ‘eft asd fod i algoithon exd han te sen i aig ie wes se SES irdfmod regs ee clled ool egibaing pe. Hove, BE les ae lcd 2 aoe to aad in a ies of bay ce ad OT rly pi eel arith pore ng iter a domed 0 Boned APRESS ca 89 i) interior point have teen filed. ThE ough piel postions vat! “Feuer Ess oe Read two comers ( (Ws, Wy; and Wi WY): i for two 3. Assign the region codes 3. Ast rp, and P, using following Oe vy Fig. Q.4.1 code with bits 0000 (Ws) (> Wx,) Gy < Wy.) = (> Wy) ity of line P, Pp cs for both endpoints P, and P2 are zero then the line ible, Hence draw the line and go to step 9. a) If region cod is completely vist 1) IF region codes for endpoints are not zero and the logical ANDing vriem is also non-zero then the line is completely invisible, so ‘eject the line and go to step 9. do not satisfy the conditions in ) If region codes for two ends 42) and 4b)ihe Tine is partial 5, Determine the intersecting edge of the clipping window by inspecting the region codes of two endpoints. 4) If region codes forboth the end points are non-zero, find intersection points A andP) with boundary edges of clipping ‘window with respect to point P, and point Ps, respectively ; Y)IF region code for any one end point is non-zero then find ge intersection point P{ or Pf with the boundary edge of the clipping 6, Divide the line segments considering intersection points. on ce i on ny on pit of geass ff Darr ti i le — QS “A Gude Jor Engineering Students Graphles oe se na use te Conen-Sutierind one fowing and Clipping a5 (40, 15) - Ps (75, 4: mutcode algorithm to pines eso. 10), B (Bo, and P, (70, 20) P, (100, 10) cin jndow & 0" 2 (80, 10), C (80, 40), D(S0,40), ), 10) against a on : Line 1: P; (40, 15) Py FH Doc.-12, Marks 8 } (75, 45) x, = se ) = 50 yy=10 x= 80 it End point ndeode Din, a am axing Position " ioe Parially visible mY = MOL— +9, = $ (50—40)+ 15 m= S515. 6 5-907 = 23.87 x 2 yp x = x0 4{ SE] Or yn ~40+(Z)0- 15) = 69.16 1, = (60, 23.57) 1, = (69.06, 40) PATS, 4 (60, 40) oo P,(40, 15) (60, 10) Fig. 0.5.4 Line 2: P (70, 20) Py (100, 10) (0, 10) Point End code ANDing Ps 0000 0000 Pe oo10 Slope m’ = 19720 it St 00-70 30S xgey =m (iq 4) + ¥, = GO 70) + 20 = 1686 (80, 16.66) cate for Engineering Soderss — Computer Gropiles Mindoning and Ciping used for polygon clipping 2 sar{SPPU : May-10, Marks rn sit be cas Can tise clning sonihe Fig, 0.6.3 Disjolnt polygons in polygon clipping wn in the Fig. Q63, For examy f are frequenily included in the clipped polygon Dec.-06,07,08,11,14,17,18, Marks 6, se ISPPU : 4 May-10,14, Marks 8] (@) After etlpping (o) etre elpoing Fig. Q6.4 Polygon cliping dono by line clipping algorithm co-ordinates of all vertices of the polygon. -o-ordinates of the clipping window. consider the left edge of the window. 7 4 Compare the vertices of each edge of the polygon, individually wit clipping plane. oa ag ere “A Gude for Enginceriog Sods ows

You might also like