For junior- to graduate-level courses in computer graphics. Assuming no background in computer graphics, this junior- to graduate-level textbook presents basic principles for the design, use, and understanding of computer graphics systems and applications. The authors, authorities in their field, offer an integrated approach to two-dimensional and three-dimensional graphics topics. A comprehensive explanation of the popular OpenGL programming package, along with C++ programming examples illustrates applications of the various functions in the OpenGL basic library and the related GLU and GLUT packages.
Preface xxi About the Authors xxvi 1 Computer Graphics Hardware 9 1-1 Video Display Devices 10 Refresh Cathode-Ray Tubes 10 Raster-Scan Displays 13 Random-Scan Displays 15 Color CRT Monitors 16 Flat-Panel Displays 18 Three-Dimensional Viewing Devices 20 Stereoscopic and Virtual-Reality Systems 21 1-2 Raster-Scan Systems 22 Video Controller 22 Raster-Scan Display Processor 24 1-3 GraphicsWorkstations and Viewing Systems 25 1-4 Input Devices 26 Keyboards, Button Boxes, and Dials 26 Mouse Devices 26 Trackballs and Spaceballs 27 Joysticks 27 Data Gloves 28 Digitizers 28 Image Scanners 29 Touch Panels 29 Light Pens 30 Voice Systems 30 1-5 Hard-Copy Devices 30 1-6 Graphics Networks 32 1-7 Graphics on the Internet 32 1-8 Summary 33 2 Computer Graphics Software 35 2-1 Coordinate Representations 36 2-2 Graphics Functions 37 2-3 Software Standards 38 2-4 Other Graphics Packages 39 2-5 Introduction to OpenGL 40 Basic OpenGL Syntax 40 Related Libraries 40 Header Files 41 Display-Window Management Using GLUT 42 A Complete OpenGL Program 43 Error Handling in OpenGL 47 2-6 Summary 48 3 Graphics Output Primitives 51 3-1 Coordinate Reference Frames 52 Screen Coordinates 52 Absolute and Relative Coordinate Specifications 53 3-2 Specifying A Two-Dimensional World-Coordinate Reference Frame in OpenGL 54 3-3 OpenGL Point Functions 55 3-4 OpenGL Line Functions 57 3-5 OpenGL Curve Functions 58 3-6 Fill-Area Primitives 59 3-7 Polygon Fill Areas 60 Polygon Classifications 61 Identifying Concave Polygons 61 Splitting Concave Polygons 62 Splitting a Convex Polygon into a Setof Triangles 63 Inside-Outside Tests 63 Polygon Tables 66 Plane Equations 67 Front and Back Polygon Faces 68 3-8 OpenGL Polygon Fill-Area Functions 70 3-9 OpenGL Vertex Arrays 76 3-10 Pixel-Array Primitives 78 3-11 OpenGL Pixel-Array Functions 79 OpenGL Bitmap Function 79 OpenGL Pixmap Function 81 OpenGL Raster Operations 82 3-12 Character Primitives 83 3-13 OpenGL Character Functions 85 3-14 Picture Partitioning 86 3-15 OpenGL Display Lists 87 Creating and Naming an OpenGL Display List 87 Executing OpenGL Display Lists 88 Deleting OpenGL Display Lists 89 3-16 OpenGL Display-Window Reshape Function 89 3-17 Summary 92 4 Attributes of Graphics Primitives 105 4-1 OpenGL State Variables 106 4-2 Color and Grayscale 106 RGB Color Components 106 Color Tables 107 Grayscale 108 Other Color Parameters 109 4-3 OpenGL Color Functions 109 The OpenGL RGB and RGBA Color Modes 109 OpenGL Color-Index Mode 110 OpenGL Color Blending 111 OpenGL Color Arrays 112 Other OpenGL Color Functions 114 4-4 Point Attributes 115 4-5 OpenGL Point-Attribute Functions 115 4-6 Line Attributes 115 Line Width 115 Line Style 116 Pen and Brush Options 116 4-7 OpenGL Line-Attribute Functions 117 OpenGL Line-Width Function 117 OpenGL Line-Style Function 117 Other OpenGL Line Effects 119 4-8 Curve Attributes 119 4-9 Fill-Area Attributes 120 Fill Styles 120 Color-Blended Fill Regions 121 4-10 OpenGL Fill-Area Attribute Functions 121 OpenGL Fill-Pattern Function 121 OpenGL Texture and Interpolation Patterns 122 OpenGL Wire-Frame Methods 123 OpenGL Front-Face Function 126 4-11 Character Attributes 126 4-12 OpenGL Character-Attribute Functions 129 4-13 OpenGL Antialiasing Functions 129 4-14 OpenGL Query Functions 130 4-15 OpenGL Attribute Groups 131 4-16 Summary 131 5 Implementation Algorithms for Graphics Primitives and Attributes 137 5-1 Line-Drawing Algorithms 138 Line Equations 138 DDA Algorithm 139 Bresenhams Line Algorithm 140 Displaying Polylines 144 5-2 Parallel Line Algorithms 144 5-3 Setting Frame-Buffer Values 146 5-4 Circle-Generating Algorithms 147 Properties of Circles 147 Midpoint Circle Algorithm 149 5-5 Ellipse-Generating Algorithms 153 Properties of Ellipses 153 Midpoint Ellipse Algorithm 154 5-6 Other Curves 160 Conic Sections 161 Polynomials and Spline Curves 162 5-7 Parallel Curve Algorithms 163 5-8 Pixel Addressing and Object Geometry 163 Screen Grid Coordinates 164 Maintaining Geometric Properties of Displayed Objects 164 5-9 Attribute Implementations for Straight-Line Segments and Curves 166 Line Width 166 Line Style 168 Pen and Brush Options 169 Curve Attributes 170 5-10 General Scan-Line Polygon-Fill Algorithm 171 5-11 Scan-Line Fill of Convex Polygons 175 5-12 Scan-Line Fill for Regions with Curved Boundaries 176 5-13 Fill Methods for Areas with Irregular Boundaries 176 Boundary-Fill Algorithm 176 Flood-Fill Algorithm 180 5-14 Implementation Methods for Fill Styles 180 Fill Styles 181 Color-Blended Fill Regions 181 5-15 Implementation Methods for Antialiasing 183 Supersampling Straight-Line Segments 184 Subpixel Weighting Masks 186 Area Sampling Straight-Line Segments 186 Filtering Techniques 186 Pixel Phasing 186 Compensating for Line-Intensity Differences 187 Antialiasing Area Boundaries 188 5-16 Summary 190 6 Two-Dimensional Geometric Transformations 195 6-1 Basic Two-Dimensional Geometric Transformations 196 Two-Dimensional Translation 196 Two-Dimensional Rotation 198 Two-Dimensional Scaling 200 6-2 Matrix Representations and Homogeneous Coordinates 201 Homogeneous Coordinates 202 Two-Dimensional Translation Matrix 203 Two-Dimensional Rotation Matrix 203 Two-Dimensional Scaling Matrix 203 6-3 Inverse Transformations 204 6-4 Two-Dimensional Composite Transformations 204 Composite Two-Dimensional Translations 205 Composite Two-Dimensional Rotations 205 Composite Two-Dimensional Scalings 205 General Two-Dimensional Pivot-Point Rotation 206 General Two-Dimensional Fixed-Point Scaling 206 General Two-Dimensional Scaling Directions 207 Matrix Concatenation Properties 208 General Two-Dimensional Composite Transformations and Computational Efficiency 209 Two-Dimensional Rigid-Body Transformation 210 Constructing Two-Dimensional Rotation Matrices 211 Two-Dimensional Composite-Matrix Programming Example 211 6-5 Other Two-Dimensional Transformations 216 Reflection 216 Shear 218 6-6 Raster Methods for Geometric Transformations 220 6-7 OpenGL Raster Transformations 221 6-8 Transformations between Two-Dimensional Coordinate Systems 222 6-9 OpenGL Functions for Two-Dimensional Geometric Transformations 224 Basic OpenGL Geometric Transformations 224 OpenGL Matrix Operations 226 -10 OpenGL Geometric-Transformation Programming Examples 228 6-11 Summary 229 7 Two-Dimensional Viewing 233 7-1 The Two-Dimensional Viewing Pipeline 234 7-2 The ClippingWindow 235 Viewing-Coordinate Clipping Window 236 World-Coordinate Clipping Window 236 7-3 Normalization and Viewport Transformations 237 Mapping the Clipping Window into a Normalized Viewport 237 Mapping the Clipping Window into a Normalized Square 239 Display of Character Strings 241 Split-Screen Effects and Multiple Output Devices 241 7-4 OpenGL Two-Dimensional Viewing Functions 241 OpenGL Projection Mode 241 GLU Clipping-Window Function 242 OpenGL Viewport Function 242 Creating a GLUT Display Window 243 Setting the GLUT Display-Window Mode and Color 244 GLUT Display-Window Identifier 244 Deleting a GLUT Display Window 244 Current GLUT Display Window 244 Relocating and Resizing a GLUT Display Window 245 Managing Multiple GLUT Display Windows 245 GLUT Subwindows 246 Selecting a Display-Window Screen-Cursor Shape 246 Viewing Graphics Objects in a GLUT Display Window 247 Executing the Application Program 247 Other GLUT Functions 248 OpenGL Two-Dimensional Viewing Program Example 248 7-5 Clipping Algorithms 250 7-6 Two-Dimensional Point Clipping 250 7-7 Two-Dimensional Line Clipping 251 Cohen-Sutherland Line Clipping 252 Liang-Barsky Line Clipping 257 Nicholl-Lee-Nicholl Line Clipping 260 Line Clipping Using Nonrectangular Polygon Clip Windows 262 Line Clipping Using Nonlinear Clipping-Window Boundaries 262 7-8 Polygon Fill-Area Clipping 263 Sutherland--Hodgman Polygon Clipping 265 Weiler-Atherton Polygon Clipping 269 Polygon Clipping Using Nonrectangular Polygon Clip Windows 271 Polygon Clipping Using Nonlinear Clipping-Window Boundaries 272 7-9 Curve Clipping 272 7-10 Text Clipping 273 7-11 Summary 274 8 Three-Dimensional Geometric Transformations 279 8-1 Three-Dimensional Translation 280 8-2 Three-Dimensional Rotation 281 Three-Dimensional Coordinate-Axis Rotations 282 General Three-Dimensional Rotations 284 Quaternion Methods for Three-Dimensional Rotations 289 8-3 Three-Dimensional Scaling 293 8-4 Composite Three-Dimensional Transformations 295 8-5 Other Three-Dimensional Transformations 298 Three-Dimensional Reflections 298 Three-Dimensional Shears 299 8-6 Transformations between Three-Dimensional Coordinate Systems 299 8-7 Affine Transformations 300 8-8 OpenGL Geometric-Transformation Functions 300 OpenGL Matrix Stacks 300 8-9 OpenGL Three-Dimensional Geometric-Transformation Programming Examples 302 8-10 Summary 303 9 Three-Dimensional Viewing 307 9-1 Overview of Three-Dimensional Viewing Concepts 308 Viewing a Three-Dimensional Scene 308 Projections 308 Depth Cueing 309 Identifying Visible Lines and Surfaces 309 Surface Rendering 309 Exploded and Cutaway Views 309 Three-Dimensional and Stereoscopic Viewing 310 9-2 The Three-Dimensional Viewing Pipeline 310 9-3 Three-Dimensional Viewing-Coordinate Parameters 312 The View-Plane Normal Vector 312 The View-Up Vector 313 The uvn Viewing-Coordinate Reference Frame 313 Generating Three-Dimensional Viewing Effects 314 9-4 Transformation fromWorld to Viewing Coordinates 314 9-5 Projection Transformations 316 9-6 Orthogonal Projections 316 Axonometric and Isometric Orthogonal Projections 317 Orthogonal Projection Coordinates 317 Clipping Window and Orthogonal-Projection View Volume 318 Normalization Transformation for an Orthogonal Projection 320 9-7 Oblique Parallel Projections 321 Oblique Parallel Projections in Drafting and Design 322 Cavalier and Cabinet Oblique Parallel Projections 323 Oblique Parallel-Projection Vector 324 Clipping Window and Oblique Parallel-Projection View Volume 325 Oblique Parallel-Projection Transformation Matrix 325 Normalization Transformation for an Oblique Parallel Projection 326 9-8 Perspective Projections 327 Perspective-Projection Transformation Coordinates 327 Perspective-Projection Equations: Special Cases 328 Vanishing Points for Perspective Projections 330 Perspective-Projection View Volume 331 Perspective-Projection Transformation Matrix 332 Symmetric Perspective-Projection Frustum 333 Oblique Perspective-Projection Frustum 335 Normalized Perspective-Projection Transformation Coordinates 338 9-9 The Viewport Transformation and Three- Dimensional Screen Coordinates 341 9-10 OpenGL Three-Dimensional Viewing Functions 341 OpenGL Viewing-Transformation Function 342 OpenGL Orthogonal-Projection Function 342 OpenGL Symmetric Perspective-Projection Function 344 OpenGL General Perspective-Projection Function 344 OpenGL Viewports and Display Windows 345 OpenGL Three-Dimensional Viewing Program Example 345 10-11 Three-Dimensional Clipping Algorithms 347 Clipping in Three-Dimensional Homogeneous Coordinates 348 Three-Dimensional Region Codes 349 Three-Dimensional Point and Line Clipping 350 Three-Dimensional Polygon Clipping 352 Three-Dimensional Curve Clipping 353 Arbitrary Clipping Planes 353 9-12 OpenGL Optional Clipping Planes 355 9-13 Summary 356 10 Hierarchical Modeling 359 10-1 Basic Modeling Concepts 360 System Representations 360 Symbol Hierarchies 361 10-2 Modeling Packages 363 10-3 General Hierarchical Modeling Methods 363 Local Coordinates 364 Modeling Transformations 364 Creating Hierarchical Structures 364 10-4 Hierarchical Modeling Using OpenGL Display Lists 366 10-5 Summary 367 11 Computer Animation 369 11-1 Raster Methods for Computer Animation 370 Double Buffering 370 Generating Animations Using Raster Operations 371 11-2 Design of Animation Sequences 372 11-3 Traditional Animation Techniques 373 11-4 General Computer-Animation Functions 374 11-5 Computer-Animation Languages 374 11-6 Key-Frame Systems 375 Morphing 375 Simulating Accelerations 377 11-7 Motion Specifications 380 Direct Motion Specification 380 Goal-Directed Systems 380 Kinematics and Dynamics 381 11-8 Character Animation 382 Articulated Figure Animation 382 Motion Capture 383 11-9 Periodic Motions 384 11-10 OpenGL Animation Procedures 385 11-11 Summary 388 12 Three-Dimensional Object Representations 393 12-1 Polyhedra 394 12-2 OpenGL Polyhedron Functions 394 OpenGL Polygon Fill-Area Functions 394 GLUT Regular Polyhedron Functions 394 Example GLUT Polyhedron Program 396 12-3 Curved Surfaces 397 12-4 Quadric Surfaces 398 Sphere 398 Ellipsoid 398 Torus 399 12-5 Superquadrics 400 Superellipse 400 Superellipsoid 401 12-6 OpenGL Quadric-Surface and Cubic-Surface Functions 401 GLUT Quadric-Surface Functions 401 GLUT Cubic-Surface Teapot Function 402 GLU Quadric-Surface Functions 403 Example Program Using GLUT and GLU Quadric-Surface Functions 405 12-7 Summary 407 13 Spline Representations 411 13-1 Interpolation and Approximation Splines 412 13-2 Parametric Continuity Conditions 413 13-3 Geometric Continuity Conditions 414 13-4 Spline Specifications 415 13-5 Spline Surfaces 416 13-6 Trimming Spline Surfaces 416 13-7 Cubic-Spline Interpolation Methods 417 Natural Cubic Splines 417 Hermite Interpolation 418 Cardinal Splines 419 Kochanek-Bartels Splines 423 13-8 Bezier Spline Curves 423 Bezier Curve Equations 424 Example Bezier Curve-Generating Program 425 Properties of Bezier Curves 428 Design Techniques Using Bezier Curves 429 Cubic Bezier Curves 430 13-9 Bezier Surfaces 431 13-10 B-Spline Curves 433 B-Spline Curve Equations 433 Uniform Periodic B-Spline Curves 434 Cubic Periodic B-Spline Curves 437 Open Uniform B-Spline Curves 439 Nonuniform B-Spline Curves 440 13-11 B-Spline Surfaces 442 13-12 Beta-Splines 442 Beta-Spline Continuity Conditions 442 Cubic Periodic Beta-Spline Matrix Representation 443 13-13 Rational Splines 443 13-14 Conversion Between Spline Representations 445 13-15 Displaying Spline Curves and Surfaces 446 Horners Rule 447 Forward-Difference Calculations 447 Subdivision Methods 448 13-16 OpenGL Approximation-Spline Functions 450 OpenGL Bezier-Spline Curve Functions 450 OpenGL Bezier-Spline Surface Functions 453 GLU B-Spline Curve Functions 455 GLU B-Spline Surface Functions 457 GLU Surface-Trimming Functions 459 13-17 Summary 461 14 Visible-Surface Detection Methods 479 14-1 Classification of Visible-Surface Detection Algorithms 480 14-2 Back-Face Detection 480 14-3 Depth-Buffer Method 481 14-4 A-Buffer Method 484 14-5 Scan-Line Method 486 14-6 Depth-Sorting Method 487 14-7 BSP-Tree Method 490 14-8 Area-Subdivision Method 491 14-9 Octree Methods 493 14-10 Ray-Casting Method 494 14-11 Comparison of Visibility-Detection Methods 495 14-12 Curved Surfaces 496 C5rved-Surface Representations 496 Surface Contour Plots 496 14-13 Wire-Frame Visibility Methods 497 Wire-Frame Surface-Visibility Algorithms 497 Wire-Frame Depth-Cueing Algorithm 498 14-14 OpenGL Visibility-Detection Functions 499 OpenGL Polygon-Culling Functions 499 OpenGL Depth-Buffer Functions 499 OpenGL Wire-Frame Surface-Visibility Methods 501 OpenGL Depth-Cueing Function 501 14-15 Summary 502 15 Illumination Models and Surface-Rendering Methods 507 15-1 Light Sources 508 Point Light Sources 509 Infinitely Distant Light Sources 509 Radial Intensity Attenuation 509 Directional Light Sources and Spotlight Effects 510 Angular Intensity Attenuation 511 Extended Light Sources and the Warn Model 512 15-2 Surface Lighting Effects 512 15-3 Basic Illumination Models 513 Ambient Light 513 Diffuse Reflection 514 Specular Reflection and the Phong Model 516 Combined Diffuse and Specular Reflections 519 Diffuse and Specular Reflections from Multiple Light Sources 519 Surface Light Emissions 519 Basic Illumination Model with Intensity Attenuation and Spotlights 520 RGB Color Considerations 521 Other Color Representations 522 Luminance 522 15-4 Transparent Surfaces 522 Translucent Materials 523 Light Refraction 523 Basic Transparency Model 524 15-5 Atmospheric Effects 525 15-6 Shadows 526 15-7 Camera Parameters 526 15-8 Displaying Light Intensities 526 Distributing System Intensity Levels 527 Gamma Correction and Video Lookup Tables 528 Displaying Continuous-Tone Images 529 15-9 Halftone Patterns and Dithering Techniques 529 Halftone Approximations 531 Dithering Techniques 533 15-10 Polygon Rendering Methods 535 Constant-Intensity Surface Rendering 536 Gouraud Surface Rendering 536 Phong Surface Rendering 538 Fast Phong Surface Rendering 539 15-11 OpenGL Illumination and Surface-Rendering Functions 540 OpenGL Point Light-Source Function 540 Specifying an OpenGL Light-Source Position and Type 541 Specifying OpenGL Light-Source Colors 542 Specifying Radial-Intensity Attenuation Coefficients for an OpenGL Light Source 543 OpenGL Directional Light Sources (Spotlights) 543 OpenGL Global Lighting Parameters 544 OpenGL Surface-Property Function 545 OpenGL Illumination Model 546 OpenGL Atmospheric Effects 547 OpenGL Transparency Functions 548 OpenGL Surface-Rendering Functions 549 OpenGL Halftoning Operations 550 15-12 Summary 551 16 Texturing and Surface-Detail Methods 555 16-1 Modeling Surface Detail with Polygons 556 16-2 Texture Mapping 556 Linear Texture Patterns 557 Surface Texture Patterns 557 Volume Texture Patterns 560 Texture Reduction Patterns 561 Procedural Texturing Methods 561 16-3 Bump Mapping 561 16-4 Frame Mapping 562 16-5 OpenGL Texture Functions 563 OpenGL Line-Texture Functions 563 OpenGL Surface-Texture Functions 566 OpenGL Volume-Texture Functions 568 OpenGL Color Options for Texture Patterns 568 OpenGL Texture-Mapping Options 569 OpenGL Texture Wrapping 569 Copying OpenGL Texture Patterns from the Frame Buffer 570 OpenGL Texture-Coordinate Arrays 570 Naming OpenGL Texture Patterns 570 OpenGL Texture Subpatterns 572 OpenGL Texture Reduction Patterns 572 OpenGL Texture Borders 573 OpenGL Proxy Textures 573 Automatic Texturing of Quadric Surfaces 574 Homogeneous Texture Coordinates 574 Additional OpenGL Texture Options 575 16-6 Summary 575 17 Color Models and Color Applications 579 17-1 Properties of Light 580 The Electromagnetic Spectrum 580 Psychological Characteristics of Color 581 17-2 Color Models 582 Primary Colors 582 Intuitive Color Concepts 583 17-3 Standard Primaries and the Chromaticity Diagram 583 The XYZ Color Model 584 Normalized XYZ Values 584 The CIE Chromaticity Diagram 585 Color Gamuts 585 Complementary Colors 585 Dominant Wavelength 586 Purity 586 17-4 The RGB Color Model 586 17-5 The YIQ and Related Color Models 588 The YIQ Parameters 588 Transformations Between RGB and YIQ Color Spaces 588 The YUV and YCrCb Systems 589 17-6 The CMY and CMYK Color Models 589 The CMY Parameters 589 Transformations Between CMY and RGB Color Spaces 590 17-7 The HSV Color Model 590 The HSV Parameters 590 Selecting Shades, Tints, and Tones 591 Transformations Between HSV and RGB Color Spaces 592 17-8 The HLS Color Model 594 17-9 Color Selection and Applications 595 17-10 Summary 595 18 Interactive Input Methods and Graphical User Interfaces 599 18-1 Graphical Input Data 600 18-2 Logical Classification of Input Devices 600 Locator Devices 600 Stroke Devices 601 String Devices 601 Valuator Devices 601 Choice Devices 601 Pick Devices 602 18-3 Input Functions for Graphical Data 603 Input Modes 604 Echo Feedback 604 Callback Functions 604 18-4 Interactive Picture-Construction Techniques 605 Basic Positioning Methods 605 Dragging 605 Constraints 605 Grids 606 Rubber-Band Methods 606 Gravity Field 607 Interactive Painting and Drawing Methods 607 18-5 Virtual-Reality Environments 608 18-6 OpenGL Interactive Input-Device Functions 608 GLUT Mouse Functions 609 GLUT Keyboard Functions 613 GLUT Tablet Functions 617 GLUT Spaceball Functions 618 GLUT Button-Box Function 618 GLUT Dials Function 618 OpenGL Picking Operations 619 18-7 OpenGL Menu Functions 624 Creating a GLUT Menu 624 Creating and Managing Multiple GLUT Menus 626 Creating GLUT Submenus 627 Modifying GLUT Menus 629 18-8 Designing a Graphical User Interface 630 The User Dialogue 630 Windows and Icons 630 Accommodating Multiple Skill Levels 631 Consistency 631 Minimizing Memorization 631 Backup and Error Handling 632 Feedback 632 18-9 Summary 633 19 Global Illumination 639 19-1 Ray-Tracing Methods 640 Basic Ray-Tracing Algorithm 640 Ray-Surface Intersection Calculations 643 Ray-Sphere Intersections 644 Ray-Polyhedron Intersections 645 Reducing Object-Intersection Calculations 646 Space-Subdivision Methods 646 Simulating Camera Focusing Effects 648 Antialiased Ray Tracing 650 Distributed Ray Tracing 651 19-2 Radiosity Lighting Model 654 Radiant-Energy Terms 654 The Basic Radiosity Model 655 Progressive Refinement Radiosity Method 658 19-3 Environment Mapping 660 19-4 Photon Mapping 661 19-5 Summary 662 20 Programmable Shaders 665 20-1 A History of Shading Languages 666 Cooks Shade Trees 666 Perlins Pixel Stream Editor 668 RenderMan 668 20-2 The OpenGL Pipeline 670 The Fixed-Function Pipeline 670 Changing the Pipeline Structure 671 Vertex Shaders 672 Fragment Shaders 672 Geometry Shaders 672 Tessellation Shaders 672 20-3 The OpenGL Shading Language 673 Shader Structure 673 Using Shaders in OpenGL 675 Basic Data Types 679 Vectors 679 Matrices 680 Structures and Arrays 680 Control Structures 681 GLSL Functions 681 Communicating with OpenGL 682 20-4 Shader Effects 683 A Phong Shader 684 Texture Mapping 687 Bump Mapping 689 20-5 Summary 693 21 Algorithmic Modeling 695 21-1 Fractal-Geometry Methods 696 Fractal Generation Procedures 697 Classification of Fractals 697 Fractal Dimension 698 Geometric Construction of Deterministic Self-Similar Fractals 700 Geometric Construction of Statistically Self-Similar Fractals 703 Affine Fractal-Construction Methods 704 Random Midpoint-Displacement Methods 704 Controlling Terrain Topography 706 Self-Squaring Fractals 708 Self-Inverse Fractals 717 21-2 Particle Systems 719 21-3 Grammar-Based Modeling Methods 720 21-4 Summary 722 22 Visualization of Data Sets 725 22-1 Visual Representations for Scalar Fields 726 22-2 Visual Representations for Vector Fields 728 22-3 Visual Representations for Tensor Fields 728 22-4 Visual Representations for Multivariate Data Fields 729 22-5 Summary 729 A Mathematics for ComputerGraphics 731 A-1 Coordinate Reference Frames 731 Two-Dimensional Cartesian Screen Coordinates 731 Standard Two-Dimensional Cartesian Reference Frames 732 Polar Coordinates in the xy Plane 732 Standard Three-Dimensional Cartesian Reference Frames 733 Three-Dimensional Cartesian Screen Coordinates 733 Three-Dimensional Curvilinear-Coordinate Systems 734 Solid Angle 735 A-2 Points and Vectors 735 Point Properties 735 Vector Properties 736 Vector Addition and Scalar Multiplication 737 Scalar Product of Two Vectors 738 Vector Product of Two Vectors 738 A-3 Tensors 739 A-4 Basis Vectors and the Metric Tensor 739 Determining Basis Vectors for a Coordinate Space 740 Orthonormal Basis 740 Metric Tensor 741 A-5 Matrices 742 Scalar Multiplication and Matrix Addition 742 Matrix Multiplication 743 Matrix Transpose 744 Determinant of a Matrix 744 Matrix Inverse 744 A-6 Complex Numbers 745 Basic Complex Arithmetic 745 Imaginary Unit 746 Complex Conjugate and Modulus of a Complex Number 746 Complex Division 746 Polar-Coordinate Representation for a Complex Number 747 A-7 Quaternions 747 A-8 Nonparametric Representations 748 A-9 Parametric Representations 749 A-10 Rate-of-Change Operators 750 Gradient Operator 750 Directional Derivative 751 General Form of the Gradient Operator 751 Laplace Operator 751 Divergence Operator 752 Curl Operator 752 A-11 Rate-of-Change Integral Transformation Theorems 752 Stokess Theorem 753 Greens Theorem for a Plane Surface 753 Divergence Theorem 754 Greens Transformation Equations 755 A-12 Area and Centroid of a Polygon 755 Area of a Polygon 755 Centroid of a Polygon 756 A-13 Calculating Properties of Polyhedra 757 A-14 Numerical Methods 758 Solving Sets of Linear Equations 758 Finding Roots of Nonlinear Equations 760 Evaluating Integrals 761 Solving Ordinary Differential Equations 763 Solving Partial Differential Equations 764 Least-Squares Curve-Fitting Methods for Data Sets 765 B Graphics File Formats 767 B-1 Image-File Configurations 767 B-2 Color-Reduction Methods 768 Uniform Color Reduction 768 Popularity Color Reduction 768 Median-Cut Color Reduction 769 B-3 File-Compression Techniques 769 Run-Length Encoding 770 LZW Encoding 770 Other Pattern-Recognition Compression Methods 771 Huffman Encoding 771 Arithmetic Encoding 773 Discrete Cosine Transform 774 B-4 Composition of the Major File Formats 776 JPEG: Joint Photographic Experts Group 776 CGM: Computer-Graphics Metafile Format 778 TIFF: Tag Image-File Format 778 PNG: Portable Network-Graphics Format 779 XBM: X Window System Bitmap Format and XPM: X Window System Pixmap Format 779 Adobe Photoshop Format 779 MacPaint: Macintosh Paint Format 780 PICT: Picture Data Format 780 BMP: Bitmap Format 780 PCX: PC Paintbrush File Format 780 TGA: Truevision Graphics-Adapter Format 780 GIF: Graphics Interchange Format 781 B-5 Summary 781 C-1 The Evolution of OpenGL 783 The Early Years: OpenGL 1.x 784 OpenGL Goes Tiny: OpenGL ES 1.x 785 Under New Management: OpenGL and Khronos Group 786 Programmable Everything: OpenGL 2.x 786 Tiny Programs: OpenGL ES 2.x 787 Geometry and Vertex Processing Evolution: OpenGL 3.x 787 This Generation: OpenGL 4.x 789 The OpenGL Extension Mechanism 790 Where Next? 791 C-2 OpenGL beyond C and C++ 792 OpenGL for Java 792 Multithreading 795 Python and OpenGL 798 Conclusions and Directions 803 C-3 GPU Architecture, Past, Present, and Future 803 The Early Days 804 The Middle Ages 805 Modern GPUs 806 Parallelism 806 Getting the Most out of a Modern GPU 810 Balance the Workload 810 Always Move Forwards 811 Feed the Pipeline 811 Make Best Use of Your Resources 811 Bibliography 813 Index 825 OpenGL Function Index 859 Core Library Functions 859 GLSL Library Functions 860 GLU Library Functions 861 GLUT Library Functions 861