100% found this document useful (2 votes)
699 views

Download full Computer graphics through openGL Third Edition Guha ebook all chapters

graphics

Uploaded by

thonggaterhz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
699 views

Download full Computer graphics through openGL Third Edition Guha ebook all chapters

graphics

Uploaded by

thonggaterhz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Computer graphics through openGL Third Edition


Guha

https://textbookfull.com/product/computer-graphics-through-
opengl-third-edition-guha/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Computer Graphics Through OpenGL: From Theory to


Experiments Sumanta Guha

https://textbookfull.com/product/computer-graphics-through-opengl-
from-theory-to-experiments-sumanta-guha/

textboxfull.com

Computer Graphics Programming in OpenGL Using C++, Third


Edition Gordon Phd

https://textbookfull.com/product/computer-graphics-programming-in-
opengl-using-c-third-edition-gordon-phd/

textboxfull.com

Computer Graphics Programming in OpenGL with Java Gordon

https://textbookfull.com/product/computer-graphics-programming-in-
opengl-with-java-gordon/

textboxfull.com

Introduction to Computer Graphics with OpenGL ES First


Edition Junghyun Han

https://textbookfull.com/product/introduction-to-computer-graphics-
with-opengl-es-first-edition-junghyun-han/

textboxfull.com
Computer Graphics Programming in OpenGL with Java 2nd
Edition V. Scott Gordon

https://textbookfull.com/product/computer-graphics-programming-in-
opengl-with-java-2nd-edition-v-scott-gordon/

textboxfull.com

Learn OpenGL Learn modern OpenGL graphics programming in a


step by step fashion 1st Edition Joey De Vries

https://textbookfull.com/product/learn-opengl-learn-modern-opengl-
graphics-programming-in-a-step-by-step-fashion-1st-edition-joey-de-
vries/
textboxfull.com

R Graphics (Third Edition) Paul Murrell

https://textbookfull.com/product/r-graphics-third-edition-paul-
murrell/

textboxfull.com

Fundamentals of Computer Graphics Steve Marschner

https://textbookfull.com/product/fundamentals-of-computer-graphics-
steve-marschner/

textboxfull.com

Mathematics for Computer Graphics John Vince

https://textbookfull.com/product/mathematics-for-computer-graphics-
john-vince/

textboxfull.com
Computer Graphics Through OpenGL
From Theory to Experiments
Third Edition
Computer Graphics Through OpenGL
From Theory to Experiments
Third Edition

Sumanta Guha
Asian Institute of Technology, Thailand
Cover Designed by Sumanta Guha

CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742

© 2019 by Taylor & Francis Group, LLC


CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works

Printed on acid-free paper


Version Date: 20181022

International Standard Book Number-13: 978-1-138-61264-8 (Hardback)

This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and
information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission
to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic,
mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or
retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact
the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides
licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment
has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation
without intent to infringe.

Library of Congress Cataloging-in-Publication Data

Names: Guha, Sumanta,


author.
Title: Computer graphics through openGL / Sumanta Guha.
Description: Third edition. | Boca Raton : Taylor & Francis, a CRC title,
part of the Taylor & Francis imprint, a member of the Taylor & Francis
Group, the academic division of T&F Informa, plc, 2018. | Includes
bibliographical references and index.
Identifiers: LCCN 2018027365 | ISBN 9781138612648 (hardback : acid-free paper)
Subjects: LCSH: Computer graphics. | Microcomputers--Programming. | OpenGL. |
BISAC: COMPUTERS / Computer Graphics. | MATHEMATICS / General.
Classification: LCC T385 .G85 2018 | DDC 006.6/633--dc23
LC record available at https://lccn.loc.gov/2018027365

Visit the Taylor & Francis Web site at


http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
To my parents Utpal Chandra and
Santa Guha and to Kamaladi
Contents

P REFACE XVII

A BOUT THE AUTHOR XXVII

I Hello World 1
1 A N I NVITATION TO C OMPUTER G RAPHICS 3
1.1 Brief History of Computer Graphics . . . . . . . . . . . . . . . . . . . 5
1.2 Overview of a Graphics System . . . . . . . . . . . . . . . . . . . . . . 8
1.2.1 Input Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2.2 Output Devices . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3 Quick Preview of the Adventures Ahead . . . . . . . . . . . . . . . . . 14

2 O N TO O PEN GL AND 3D C OMPUTER G RAPHICS 17


2.1 First Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 Orthographic Projection, Viewing Box and World Coordinates . . . . 19
2.3 The OpenGL Window and Screen Coordinates . . . . . . . . . . . . . 24
2.4 Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.5 Color, OpenGL State Machine and Interpolation . . . . . . . . . . . . 26
2.6 OpenGL Geometric Primitives . . . . . . . . . . . . . . . . . . . . . . 29
2.7 Approximating Curved Objects . . . . . . . . . . . . . . . . . . . . . . 35
2.8 Three Dimensions, the Depth Buffer and Perspective Projection . . . . 37
2.8.1 A Vital 3D Utility: The Depth Buffer . . . . . . . . . . . . . . 38
2.8.2 A Helix and Perspective Projection . . . . . . . . . . . . . . . 40
2.9 Drawing Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.10 Approximating Curved Objects Once More . . . . . . . . . . . . . . . 46
2.11 An OpenGL Program End to End . . . . . . . . . . . . . . . . . . . . 49
2.12 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 51

II Tricks of the Trade 53


3 A N O PEN GL T OOLBOX 55
3.1 Vertex Arrays and Their Drawing Commands . . . . . . . . . . . . . . 56
3.2 Vertex Buffer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.3 Vertex Array Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.4 Display Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 vii
CONTENTS 3.5 Drawing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.6 Programming the Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.7 Programming Non-ASCII Keys . . . . . . . . . . . . . . . . . . . . . . 69
3.8 Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.9 Line Stipples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.10 FreeGLUT Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.11 Clipping Planes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3.12 Frustum, Differently . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.13 Viewports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.14 Multiple Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.15 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 78

III Movers and Shapers 79


4 T RANSFORMATION , A NIMATION AND V IEWING 81
4.1 Modeling Transformations . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.1.1 Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.1.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.1.3 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.2 Composing Modeling Transformations . . . . . . . . . . . . . . . . . . 88
4.3 Placing Multiple Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.4 Modelview Matrix Stack and Isolating Transformations . . . . . . . . 101
4.5 Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
4.5.1 Animation Technicals . . . . . . . . . . . . . . . . . . . . . . . 103
4.5.2 Animation Code . . . . . . . . . . . . . . . . . . . . . . . . . . 106
4.5.3 Animation Projects . . . . . . . . . . . . . . . . . . . . . . . . 115
4.6 Viewing Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . 117
4.6.1 Understanding the Viewing Transformation . . . . . . . . . . . 117
4.6.2 Simulating a Viewing Transformation with Modeling Transfor-
mations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.6.3 Orientation and Euler Angles . . . . . . . . . . . . . . . . . . . 130
4.6.4 Viewing Transformation and Collision Detection in Animation 133
4.7 More Animation Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
4.7.1 Animating an Articulated Figure . . . . . . . . . . . . . . . . 136
4.7.2 Simple Orthographic Shadows . . . . . . . . . . . . . . . . . . 138
4.8 Selection and Picking . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
4.8.1 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
4.8.2 Picking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
4.9 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 145

5 I NSIDE A NIMATION : T HE T HEORY OF T RANSFORMATIONS 147


5.1 Geometric Transformations in 2-Space . . . . . . . . . . . . . . . . . . 148
5.1.1 Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5.1.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.1.3 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.1.4 Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
5.2 Affine Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
5.2.1 Affine Transformations Defined . . . . . . . . . . . . . . . . . . 154
5.2.2 Affine Transformations and OpenGL . . . . . . . . . . . . . . 158
5.2.3 Affine Transformations and Homogeneous Coordinates . . . . 160
viii 5.3 Geometric Transformations in 2-Space Continued . . . . . . . . . . . . 162
5.3.1 Affine Geometric Transformations . . . . . . . . . . . . . . . . 162 CONTENTS
5.3.2 Euclidean and Rigid Transformations . . . . . . . . . . . . . . 166
5.4 Geometric Transformations in 3-Space . . . . . . . . . . . . . . . . . . 173
5.4.1 Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
5.4.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
5.4.3 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
5.4.4 Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
5.4.5 Affine Geometric Transformations . . . . . . . . . . . . . . . . 187
5.4.6 Accessing and Manipulating the Current Modelview Matrix . 189
5.4.7 Euclidean and Rigid Transformations . . . . . . . . . . . . . . 191
5.5 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 196

6 A DVANCED A NIMATION T ECHNIQUES 197


6.1 Frustum Culling by Space Partitioning . . . . . . . . . . . . . . . . . . 197
6.1.1 Space Partitioning . . . . . . . . . . . . . . . . . . . . . . . . . 199
6.1.2 Quadtrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
6.1.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 201
6.1.4 More about Space Partitioning . . . . . . . . . . . . . . . . . . 202
6.2 Occlusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
6.2.1 Querying and Culling . . . . . . . . . . . . . . . . . . . . . . . 202
6.2.2 Conditional Rendering . . . . . . . . . . . . . . . . . . . . . . 205
6.3 Timer Queries and Performance Measurememt . . . . . . . . . . . . . 205
6.4 Animating Orientation Using Euler Angles . . . . . . . . . . . . . . . . 206
6.4.1 Euler Angles and the Orientation of a Rigid Body . . . . . . . 206
6.4.2 Animating Orientation . . . . . . . . . . . . . . . . . . . . . . 207
6.4.3 Problems with Euler Angles: Gimbal Lock and Ambiguity . . 208
6.5 Quaternions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
6.5.1 Quaternion Math 101 . . . . . . . . . . . . . . . . . . . . . . . 210
6.5.2 Quaternions and Orientation . . . . . . . . . . . . . . . . . . . 213
6.6 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 221

IV Geometry for the Home Office 223


7 C ONVEXITY AND I NTERPOLATION 225
7.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
7.2 Convex Combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
7.3 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
7.4 Convexity and the Convex Hull . . . . . . . . . . . . . . . . . . . . . . 234
7.5 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 239

8 T RIANGULATION 241
8.1 Definition and Justification . . . . . . . . . . . . . . . . . . . . . . . . 241
8.2 Steiner Vertices and the Quality of a Triangulation . . . . . . . . . . . 244
8.3 Triangulation in OpenGL and the Trouble with Non-Convexity . . . . 245
8.4 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 248

9 O RIENTATION 249
9.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
9.2 OpenGL Procedure to Determine Front and Back Faces . . . . . . . . 250
9.3 Consistently Oriented Triangulation . . . . . . . . . . . . . . . . . . . 255
9.4 Culling Obscured Faces . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.5 Transformations and the Orientation of Geometric Primitives . . . . . 261 ix
CONTENTS 9.6 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 262

V Making Things Up 263


10 M ODELING IN 3D S PACE 265
10.1 Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
10.1.1 Specifying Plane Curves . . . . . . . . . . . . . . . . . . . . . 266
10.1.2 Specifying Space Curves . . . . . . . . . . . . . . . . . . . . . 269
10.1.3 Drawing Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 271
10.1.4 Polynomial and Rational Parametrizations . . . . . . . . . . . 274
10.1.5 Conic Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
10.1.6 Curves More Formally . . . . . . . . . . . . . . . . . . . . . . . 277
10.2 Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.2.1 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.2.2 Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.2.3 Planar Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 285
10.2.4 General Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 286
10.2.5 Drawing General Surfaces . . . . . . . . . . . . . . . . . . . . . 287
10.2.6 Swept Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
10.2.7 Drawing Projects . . . . . . . . . . . . . . . . . . . . . . . . . 296
10.2.8 Ruled Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
10.2.9 Quadric Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 299
10.2.10 GLU Quadric Objects . . . . . . . . . . . . . . . . . . . . . . . 301
10.2.11 Regular Polyhedra . . . . . . . . . . . . . . . . . . . . . . . . . 303
10.2.12 Surfaces More Formally . . . . . . . . . . . . . . . . . . . . . . 307
10.3 Bézier Phrase Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
10.3.1 Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
10.3.2 Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
10.4 Importing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
10.5 Fractals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
10.6 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 324

VI Lights, Camera, Equation 327


11 C OLOR AND L IGHT 329
11.1 Vision and Color Models . . . . . . . . . . . . . . . . . . . . . . . . . . 330
11.1.1 RGB Color Model . . . . . . . . . . . . . . . . . . . . . . . . . 331
11.1.2 CMY and CMYK Color Models . . . . . . . . . . . . . . . . . 333
11.1.3 HSV (or HSB) Color Model . . . . . . . . . . . . . . . . . . . 334
11.1.4 Summary of the Models . . . . . . . . . . . . . . . . . . . . . . 334
11.2 Phong’s Lighting Model . . . . . . . . . . . . . . . . . . . . . . . . . . 335
11.2.1 Phong Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
11.2.2 Specifying Light and Material Values . . . . . . . . . . . . . . 337
11.2.3 Calculating the Reflected Light . . . . . . . . . . . . . . . . . 337
11.2.4 First Lighting Equation . . . . . . . . . . . . . . . . . . . . . . 342
11.3 OpenGL Light and Material Properties . . . . . . . . . . . . . . . . . 344
11.3.1 Light Properties . . . . . . . . . . . . . . . . . . . . . . . . . . 345
11.3.2 Material Properties . . . . . . . . . . . . . . . . . . . . . . . . 346
11.3.3 Experimenting with Properties . . . . . . . . . . . . . . . . . . 347
11.3.4 Color Material Mode . . . . . . . . . . . . . . . . . . . . . . . 350
11.4 OpenGL Lighting Model . . . . . . . . . . . . . . . . . . . . . . . . . . 351
x 11.5 Directional Lights, Positional Lights and Attenuation of Intensity . . . 353
11.6 Spotlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 CONTENTS
11.7 OpenGL Lighting Equation . . . . . . . . . . . . . . . . . . . . . . . . 356
11.8 OpenGL Shading Models . . . . . . . . . . . . . . . . . . . . . . . . . 357
11.9 Animating Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
11.10 Partial Derivatives, Tangent Planes and Normal Vectors 101 . . . . . 358
11.11 Computing Normals and Lighting Surfaces . . . . . . . . . . . . . . . 365
11.11.1 Polygons and Planar Surfaces . . . . . . . . . . . . . . . . . . 365
11.11.2 Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
11.11.3 General Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 368
11.11.4 FreeGLUT, Bézier and Quadric Surfaces . . . . . . . . . . . . 371
11.11.5 Transforming Normals . . . . . . . . . . . . . . . . . . . . . . 373
11.11.6 Normalizing Normals . . . . . . . . . . . . . . . . . . . . . . . 375
11.12 Phong’s Shading Model . . . . . . . . . . . . . . . . . . . . . . . . . . 375
11.13 Lighting Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
11.14 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . 378

12 T EXTURE 379
12.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
12.2 Texture Space, Coordinates and Map . . . . . . . . . . . . . . . . . . . 382
12.3 Repeating and Clamping . . . . . . . . . . . . . . . . . . . . . . . . . . 385
12.4 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
12.5 Specifying the Texture Map . . . . . . . . . . . . . . . . . . . . . . . . 393
12.5.1 Parametrized Surfaces . . . . . . . . . . . . . . . . . . . . . . . 393
12.5.2 Bézier and Quadric Surfaces . . . . . . . . . . . . . . . . . . . 394
12.5.3 Spheres and Mercator Projection . . . . . . . . . . . . . . . . . 395
12.6 Texture Matrix and Animating Textures . . . . . . . . . . . . . . . . . 397
12.7 Lighting Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
12.8 Multitexturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
12.9 Rendering to Texture with Framebuffer Objects . . . . . . . . . . . . . 401
12.10 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . 405

13 S PECIAL V ISUAL T ECHNIQUES 407


13.1 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
13.1.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
13.1.2 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
13.1.3 Opaque and Translucent Objects Together . . . . . . . . . . . 412
13.1.4 Blending Textures . . . . . . . . . . . . . . . . . . . . . . . . . 414
13.1.5 Creating Reflections . . . . . . . . . . . . . . . . . . . . . . . . 415
13.1.6 Motion Blur in World Space . . . . . . . . . . . . . . . . . . . 416
13.2 Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
13.3 Billboarding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
13.4 Antialiasing Points and Lines, Multisampling Polygons . . . . . . . . . 419
13.4.1 Antialiasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
13.4.2 Multisampling . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
13.5 Point Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
13.6 Environment Mapping: Sphere Mapping and Cube Mapping . . . . . . 422
13.6.1 Sphere Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . 423
13.6.2 Cube Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
13.7 Stencil Buffer Techniques . . . . . . . . . . . . . . . . . . . . . . . . . 429
13.7.1 OpenGL Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . 429
13.7.2 Using the Stencil Buffer . . . . . . . . . . . . . . . . . . . . . . 430
13.8 Image Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 xi
CONTENTS 13.9 Bump Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
13.10 Shadow Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
13.11 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . 442

VII Pixels, Pixels, Everywhere 443


14 R ASTER A LGORITHMS 445
14.1 Cohen-Sutherland Line Clipper . . . . . . . . . . . . . . . . . . . . . . 445
14.2 Sutherland-Hodgman Polygon Clipper . . . . . . . . . . . . . . . . . . 449
14.3 DDA and Bresenham’s Line Rasterizers . . . . . . . . . . . . . . . . . 451
14.4 Scan-Based Polygon Rasterizer . . . . . . . . . . . . . . . . . . . . . . 456
14.4.1 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
14.4.2 Optimizing Using Edge Coherence – Active Edge List . . . . . 462
14.5 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 466

VIII Programming Pipe Dreams 467


15 O PEN GL 4.3, S HADERS AND THE P ROGRAMMABLE P IPELINE : L IFT -
OFF 469
15.1 New Pipeline for OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . 470
15.1.1 Shaders in the Rendering Pipeline . . . . . . . . . . . . . . . . 470
15.1.2 New OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
15.2 GLSL Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
15.3 First Core GL 4.3 Program (Dissected) . . . . . . . . . . . . . . . . . 476
15.4 Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
15.5 Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
15.5.1 Per-Vertex Lighting . . . . . . . . . . . . . . . . . . . . . . . . 487
15.5.2 Per-Pixel Lighting . . . . . . . . . . . . . . . . . . . . . . . . . 490
15.6 Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
15.6.1 Procedural Textures . . . . . . . . . . . . . . . . . . . . . . . . 493
15.6.2 Specular Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
15.6.3 Normal Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
15.7 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 498

16 O PEN GL 4.3, S HADERS AND THE P ROGRAMMABLE P IPELINE : E S -


CAPE V ELOCITY 499
16.1 Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
16.1.1 VAOs and Instanced Rendering Instead of Display Lists . . . . 499
16.1.2 Clipping Planes . . . . . . . . . . . . . . . . . . . . . . . . . . 502
16.1.3 Rest of the Toolbox . . . . . . . . . . . . . . . . . . . . . . . . 503
16.2 Shader Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
16.2.1 Shader Subroutines . . . . . . . . . . . . . . . . . . . . . . . . 505
16.2.2 Multiple Program Objects . . . . . . . . . . . . . . . . . . . . 506
16.3 Special Visual Techniques . . . . . . . . . . . . . . . . . . . . . . . . . 508
16.3.1 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
16.3.2 Points and Sprites . . . . . . . . . . . . . . . . . . . . . . . . . 509
16.3.3 Remaining Effects . . . . . . . . . . . . . . . . . . . . . . . . . 511
16.4 More Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
16.4.1 Picking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
16.4.2 Transform Feedback . . . . . . . . . . . . . . . . . . . . . . . . 515
xii 16.5 Tessellation Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
16.5.1 TCS (Tessellation Control Shader) . . . . . . . . . . . . . . . . 520 CONTENTS
16.5.2 TES (Tessellation Evaluation Shader) . . . . . . . . . . . . . . 522
16.5.3 TPG (Tessellation Primitive Generator) . . . . . . . . . . . . . 524
16.6 Geometry Shaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
16.6.1 Particle System with Transform Feedback . . . . . . . . . . . . 535
16.7 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 538

IX Anatomy of Curves and Surfaces 539


17 B ÉZIER 541
17.1 Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
17.1.1 Linear Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . 542
17.1.2 Quadratic Bézier Curves . . . . . . . . . . . . . . . . . . . . . 543
17.1.3 Cubic Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . . 545
17.1.4 General Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . 547
17.2 Bézier Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
17.3 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 556

18 B-S PLINE 557


18.1 Problems with Bézier Primitives: Motivating B-Splines . . . . . . . . . 558
18.2 B-Spline Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
18.2.1 First-Order B-Splines . . . . . . . . . . . . . . . . . . . . . . . 562
18.2.2 Linear B-Splines . . . . . . . . . . . . . . . . . . . . . . . . . . 563
18.2.3 Quadratic B-Splines . . . . . . . . . . . . . . . . . . . . . . . . 566
18.2.4 Cubic B-Splines . . . . . . . . . . . . . . . . . . . . . . . . . . 569
18.2.5 General B-Splines and Non-uniform Knot Vectors . . . . . . . 571
18.3 B-Spline Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
18.4 Drawing B-Spline Curves and Surfaces . . . . . . . . . . . . . . . . . . 584
18.4.1 B-Spline Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 584
18.4.2 B-Spline Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . 585
18.4.3 Lighting and Texturing a B-Spline Surface . . . . . . . . . . . 586
18.4.4 Trimmed B-Spline Surface . . . . . . . . . . . . . . . . . . . . 587
18.5 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 589

19 H ERMITE 591
19.1 Hermite Splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
19.2 Natural Cubic Splines . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
19.3 Cardinal Splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
19.4 Hermite Surface Patches . . . . . . . . . . . . . . . . . . . . . . . . . . 597
19.5 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 599

X Well Projected 601


20 A PPLICATIONS OF P ROJECTIVE S PACES : P ROJECTION T RANSFOR -
MATIONS AND R ATIONAL C URVES 603
20.1 OpenGL Projection Transformations . . . . . . . . . . . . . . . . . . . 604
20.1.1 Viewing Box to Canonical Viewing Box . . . . . . . . . . . . . 606
20.1.2 Viewing Frustum to Canonical Viewing Box . . . . . . . . . . 607
20.1.3 Projection Matrix in the Pipeline . . . . . . . . . . . . . . . . 610
20.2 Rational Bézier and NURBS Curves and Surfaces . . . . . . . . . . . . 612
20.2.1 Rational Bézier Curves Basics . . . . . . . . . . . . . . . . . . 612
20.2.2 Drawing Rational Bézier Curves . . . . . . . . . . . . . . . . . 615 xiii
CONTENTS 20.2.3 Rational Bézier Curves and Conic Sections . . . . . . . . . . . 616
20.2.4 Properties of Rational Bézier Curves . . . . . . . . . . . . . . 617
20.2.5 Rational Bézier Curves and Projective Invariance . . . . . . . 618
20.2.6 Rational Bézier Curves in the Real World . . . . . . . . . . . . 622
20.2.7 Rational Bézier Surfaces . . . . . . . . . . . . . . . . . . . . . 622
20.2.8 The ‘R’ in NURBS . . . . . . . . . . . . . . . . . . . . . . . . 623
20.3 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 624

XI Time for a Pipe 625


21 P IPELINE O PERATION 627
21.1 Synthetic-Camera Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . 627
21.1.1 Pipeline: Preliminary Version . . . . . . . . . . . . . . . . . . 628
21.1.2 Perspective Division by Zero . . . . . . . . . . . . . . . . . . . 629
21.1.3 Rasterization with Perspectively Correct Interpolation . . . . 632
21.1.4 Revised Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . 636
21.1.5 OpenGL Fixed-function Pipeline . . . . . . . . . . . . . . . . . 637
21.1.6 1D Primitive Example . . . . . . . . . . . . . . . . . . . . . . 638
21.1.7 Exercising the Pipeline . . . . . . . . . . . . . . . . . . . . . . 641
21.2 Ray Tracing Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
21.2.1 Going Global: Shadows . . . . . . . . . . . . . . . . . . . . . . 643
21.2.2 Going Even More Global: Recursive Reflection and Transmission 645
21.2.3 Implementing Ray Tracing . . . . . . . . . . . . . . . . . . . . 648
21.3 Radiosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649
21.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649
21.3.2 Basic Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650
21.3.3 Computing Form Factors . . . . . . . . . . . . . . . . . . . . . 652
21.3.4 Solving the Radiosity Equation to Determine Patch Brightnesses 654
21.3.5 Implementing Radiosity . . . . . . . . . . . . . . . . . . . . . . 655
21.4 Summary, Notes and More Reading . . . . . . . . . . . . . . . . . . . . 656

Appendices 657
A P ROJECTIVE S PACES AND T RANSFORMATIONS 657
A.1 Motivation and Definition of the Projective Plane . . . . . . . . . . . . 658
A.2 Geometry on the Projective Plane and Point-Line Duality . . . . . . . 660
A.3 Homogeneous Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . 660
A.4 Structure of the Projective Plane . . . . . . . . . . . . . . . . . . . . . 662
A.4.1 Embedding the Real Plane in the Projective Plane . . . . . . . 662
A.4.2 A Thought Experiment . . . . . . . . . . . . . . . . . . . . . . 662
A.4.3 Regular Points and Points at Infinity . . . . . . . . . . . . . . 663
A.5 Snapshot Transformations . . . . . . . . . . . . . . . . . . . . . . . . . 665
A.6 Homogeneous Polynomial Equations . . . . . . . . . . . . . . . . . . . 669
A.6.1 More About Point-Line Duality . . . . . . . . . . . . . . . . . 670
A.6.2 Lifting an Algebraic Curve from the Real to the Projective Plane 671
A.6.3 Snapshot Transformations Algebraically . . . . . . . . . . . . . 674
A.7 The Dimension of the Projective Plane and Its Generalization to Higher
Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674
A.8 Projective Transformations Defined . . . . . . . . . . . . . . . . . . . . 675
A.9 Projective Transformations Geometrically . . . . . . . . . . . . . . . . 676
A.10 Relating Projective, Snapshot and Affine Transformations . . . . . . . 681
xiv A.10.1 Snapshot Transformations via Projective Transformations . . . 682
A.10.2 Affine Transformations via Projective Transformations . . . . 683 CONTENTS
A.11 Designer Projective Transformations . . . . . . . . . . . . . . . . . . . 685

B M ATH S ELF -T EST 691


C M ATH S ELF -T EST S OLUTIONS 697
B IBLIOGRAPHY 705
S UBJECT I NDEX 713
P ROGRAM I NDEX 730

xv
Preface

W
elcome to the third edition of Computer Graphics Through OpenGL:
From Theory to Experiments! The first edition appeared late 2010 and
the second four years after in 2014. Now, it’s been another four years in
which I received a lot of thoughtful and, happily, mostly positive feedback. I heard
from instructors, students, as well as individuals using the book for self-study. Their
observations together with my own classroom experience started me off a year ago
writing a new edition. It’s been a fairly intense past several months, most of my
waking hours spent sitting where I am now in front of the computer. But it’s been
fun too – being in communion with an imaginary reader who I am trying to enlighten
and keep engaged at the same time – and I am pleased with the result. I hope you
will be too. Let’s get to the facts.

About the Book


This is an introductory textbook on computer graphics with equal emphasis on theory
and practice. The programming language used is C++, with OpenGL as the graphics
API, which means calls are made to the OpenGL library from C++ programs. OpenGL
is taught from scratch.
The book has been written to be used as a textbook for a first college course, as
well as for self-study.
After Chapters 1-16 – the undergraduate core of the book – the reader will have a
good grasp of the concepts underpinning 3D computer graphics, as well as an ability
to code sophisticated 3D scenes and animation, including games and movies. We
begin with classical pre-shader OpenGL before proceeding to the latest OpenGL 4.x
(more about our exposition style further on). Chapters 17-21, though advanced, but
still mainstream, could be selected topics for an undergraduate course or part of a
second course.

Specs
This book comprises 21 chapters, an extended appendix on a fundamental math topic,
plus two more appendices containing a math self-test and its solutions. It comes with
approximately 180 programs, 270 experiments based on these programs, 750 exercises,
including theory and programming exercises, 110 worked examples, and 700 four-color
illustrations, include drawings and screenshots. An instructor’s manual containing
solutions to selected exercises is available from the publisher. The book was typeset
using LATEX and figures drawn in Adobe Illustrator.

From the Second Edition to the Third


• Cover to cover revision and reorganization of topics.
New topics include: xvii
Preface • Timer queries and performance measurement.
• Importing externally created objects.
• Texturing spheres.
• Framebuffer objects.
• Rendering to texture.
• Texture matrices.
• Cube mapping a skybox.
• Shadow mapping curved surfaces.
• OpenGL 4.x:
◦ Procedural textures.
◦ Specular maps.
◦ Normal maps.
◦ Multiple program objects.
◦ Particle systems with transform feedback.

• 10 new programs, 20 new experiments, 100 new exercises, 10 new examples, 50


new figures.
• Programming environment simplified, programs developed on Windows 10 and
Microsoft Visual Studio (MSVS) 2015 and tested on MSVS 2017.

Target Audience

• Students in a first university CG course, typically offered by a CS department


at a junior/senior level. This is the primary audience for which the book was
written.
• Students in a second or advanced CG course, who may use the book as
preparation or reference, depending on the goals. For example, the book would
be a useful reference for a study of 3D design – particularly, Bézier, B-spline
and NURBS theory – and of projective transformations and their applications
in CG.
• Students in a non-traditional setting, e.g., studying alone or in a professional
course or an on-line program. The author has tried to be especially considerate
of the reader on her own.
• Professional programmers, to use the book as a reference.

Prerequisites

Zero knowledge of computer graphics is presumed. However, the student is expected


to know the following:

• Basic C++ programming. There is no need to be an expert programmer. The


C++ program serves mainly as an environment for the OpenGL calls, so there’s
rarely need for fancy footwork in the C++ part itself.
• Basic math. This includes coordinate geometry, trigonometry and linear algebra,
all at college first-course level (or, even strong high school in some cases). For
intended readers of the book who may be unsure of their math preparation, we
have a self-test in Appendix B, with solutions in Appendix C. The test should
xviii tell exactly how ready you are and where the weaknesses are.
Resources Preface
The following are available through the book’s website www.sumantaguha.com:

• Sample chapters, table of contents, preface, subject and program index, math
self-test and solutions at the Home page.
• Program source code, developed on a Windows 10 platform using the Microsoft
Visual Studio Community 2015 IDE and subsequently tested to run with MSVS
Community 2017, which should run on other versions of Windows/MSVS, as
well as Mac OS and Linux platforms. The programs are arranged chapter-wise
in the top-level folder ExperimenterSource at the Downloads page.
• Guide to installing OpenGL and running the programs on a Windows/MSVS
platform at the Downloads page.
• Multiplatform Experimenter software to run the experiments at the Downloads
page. Experimenter’s interface is Experimenter.pdf, a file containing all the
experiments from the book; except for those in Chapter 1, each is clickable
to bring up the related program and workspace. Experimenter is only an aid
and not mandatory – each program is stand-alone. However, it is the most
convenient way to run experiments in their book order.
• Book figures in jpg format arranged in sequence as one PowerPoint presentation
per chapter at the Instructor page.
• Instructor’s manual with solutions to 100 problems – instructors who have
adopted the textbook can submit a request at the Instructor page.

Pedagogical Approach
Code and theory have been intertwined as far as possible in what may be called a
theory-experiment-repeat loop: often, following a theoretical discussion, the reader is
asked to perform validating experiments (run code, that is); sometimes, too, the other
way around, an experiment is followed by an explanation of what is observed. It’s
kind of like discovering physics.
Why use an API?
Needless to say, I am not a fan of the API-agnostic approach to teaching CG, where
focus is on principles only, with no programming practice.
Undergrads, typically, love to code and make things happen, so there is little
justification to denying the new student the joy of creating scenes, movies and games,
not to mention the pride of achievement. And, why not leverage the way code and
theory reinforce one another when teaching the subject, or learning on one’s own,
when one can? Would you want Physics 101 without a lab section?
Moreover, OpenGL is very well-designed and the learning curve short enough to
fully integrate into a first CG course. And, it is supported on every OS platform with
drivers for almost every graphics card on the market; so, in fact, OpenGL is there to
use for anyone who cares to.
Note to student: Our pedagogical style means that for most parts of the book you
want a computer handy to run experiments. So, if you are going to snuggle up with it
at night, make it a threesome with a notebook.
Note to instructor : Lectures on most topics – both of the theory and programming
practice – are best based around the book’s experiments, as well as those you develop
yourself. The Experimenter resource makes this convenient. Slides other than the
plentiful book figures, the latter all available on-line, are rarely necessary.
How to teach modern shader-based OpenGL?
Our point of view needs careful explanation as it is different from some of our peers’.
Firstly, to push the physics analogy one more time, even though relativistic mechanics
seems to rule the universe, in the classroom one might prefer doing classical physics
before relativity theory. xix
Preface Shaders, which are the programmable parts of the modern OpenGL pipeline, add
great flexibility and power. But, so too, do they add a fair bit of complexity – even
a cursory comparison of our very first program square.cpp from Chapter 2 with
its equivalent in fourth-generation OpenGL, squareShaderized.cpp, complemented
with a vertex and a fragment shader in Chapter 15, should convince the reader of this.
Consider more carefully, say, a vertex shader. It must compute the position
coordinates of a vertex, taking into account all transformations, both modelview and
projection. However, in the classical fixed-function pipeline the user can simply issue
commands such as glTranslatef(), glFrustum(), etc., leaving to OpenGL actual
computation of the transformed coordinates; not so for the programmable pipeline,
where the reader must write herself all the needed matrix operations in the vertex
shader. We firmly believe that the new student is best served learning first how to
transform objects according to an understanding of simply how a scene comes together
physically (e.g., a ball falls to the ground, a robot arm bends at the elbow, etc.) with
the help of ready-to-use commands like glTranslatef(), and, only later, how to
define these transforms mathematically.
Such consideration applies as well to other automatic services of the fixed-function
pipeline which allow the student to focus on phenomena, disregarding initially
implementation. For example, as an instructor, I would much prefer to teach first how
diffuse light lends three-dimensionality, specular light highlights, and so on, gently
motivating Phong’s lighting equation, leaving OpenGL to grapple with its actual
implementation, which is exactly what we do in Chapter 11.
In fact, we find an understanding of the fixed-function pipeline makes the subsequent
learning of the programmable one significantly easier because it’s then clear exactly
what the shaders should try to accomplish. For example, following the fixed-function
groundwork in Chapter 11, writing shaders to implement Phong lighting, as we do in
Chapter 15, is near trivial.
We take a similarly laissez-faire attitude to classical OpenGL syntax. So long as it
eases the learning curve we’ll put up with it. Take for example the following snippet
from our very first program square.cpp:

glBegin(GL_POLYGON);
glVertex3f(20.0, 20.0, 0.0);
glVertex3f(80.0, 20.0, 0.0);
glVertex3f(80.0, 80.0, 0.0);
glVertex3f(20.0, 80.0, 0.0);
glEnd();

Does it not scream square – even though it’s immediate mode and uses the discarded
polygon primitive? So, we prefer this for our first lesson, avoiding thereby the
distraction of a vertex array and the call glDrawArrays(GL TRIANGLE STRIP, 0, 4),
as in the equivalent 4.x program squareShaderized.cpp, our goal being a simple
introduction of the synthetic-camera model.
With these thoughts in mind the book starts in Chapter 2 with classical pre-shader
OpenGL, progressing gradually deeper into the API, developing CG ideas in parallel,
in a so-called theory-experiment-repeat loop. So, what exactly is an experiment?
An experiment consists either of running a book program – each usually simple for
the purpose of elucidating a single idea – or attempting to modify one based on an
understanding of the theory in order, typically, to achieve a particular visual result.
By the end of Chapter 14 the student will have acquired proficiency in pre-shader
OpenGL, a perfectly good API in itself. As well, equally importantly, she will have
an understanding of CG principles and those underlying the OpenGL pipeline, which
will dramatically ease her way through the concepts and syntax of OpenGL 4.x, the
newest generation of the API, covered in Chapters 15-16.
Does this kind of introduction to modern OpenGL, via the old and, possibly,
obsolete, not ingrain bad habits? Not at all, from our experience. When push comes
xx to shove, how hard is it to replace polygons with triangle strips? Or, use vertex buffer
objects (VBOs) and vertex array objects (VAOs) to store data? Does our approach Preface
cost timewise? If the goal is OpenGL 4.x, then, yes, it does take somewhat longer,
but there are various possible learning sequences through the book and 4.x certainly
can be reached and covered in a semester.
In short, then, we believe the correct way to modern OpenGL is through the
classical version of the API because this allows the learning process to begin at
a high level, so that the student can concentrate on gaining an overall end-to-end
understanding of the CG pipeline first, leaving the OpenGL system to manage low-level
processes (i.e., those inside the pipeline like setting transformation and projection
matrices, defining fragment colors, and such). Once she has a high-level mastery,
subsequently “descending” into the pipeline to take charge of fixed-function parts in
order to program them instead will, in fact, be far less arduous than if she tried to do
both – learn the basics and program the pipeline – at the same time.
Another point to note in this context is that, as noted before, classical OpenGL is
a complete API in itself which, in fact, can be more convenient for certain applications
(e.g., it allows one access to the readymade GLUT objects like spheres and toruses).
There are, as well, thousands of currently live applications written in classical OpenGL,
which are not going go to be discarded or rewritten any time soon – the reason, in fact,
for the Khronos Group to retain the compatibility version of the API – so familiarity
with older syntax can be useful for the intending professional.
What about Vulkan?
We thought you might ask. Vulkan is the much-hyped “successor” to OpenGL. It is a
highly explicit API, taking the programmer close to the hardware and asking her to
specify almost all facets of the pipeline from end to end. Benefits of programming
near the hardware include thin drivers, reduced run-time overhead and the ability to
expose parallelism in the GPU. (Vulkan is not only a 3D graphics API, but used to
program GPU-heavy compute applications as well.)
However, Vulkan’s explicitness and consequent verbosity make it highly unsuitable
as an introductory CG API. Here are some program sizes to begin with. The first
OpenGL program in the book, square.cpp, which draws a black square on a white
background, is about 90 lines of code in pre-shader 2nd generation OpenGL; a
functionally equivalent program, squareShaderized.cpp, written in OpenGL 4.3
later on in the book is 190 lines plus 25 lines of shader code; a minimal equivalent
Vulkan program, squareVulkanized.cpp, written separately by the author is 1,100
lines (no, that’s no misprint – the reader will find the program at the Downloads page
of the book’s website) plus 30 lines of shader code. Figure 1 is a screenshot.
Moreover, explicitness requires a Vulkan programmer to be familiar with the
Figure 1: Screenshot of
functioning of the graphics pipeline at a low level in order to specify it, which almost squareVulkanized.cpp, a
instantly disqualifies it from being a beginner’s API. Further, delaying programming 1000+ line Vulkan
until after the pipeline has been covered goes utterly against our own pedagogical program.
approach which is to engage students with code the first day.
So, is OpenGL, or for that matter, this book, of any use for someone intending to
learn Vulkan? Well:
(a) The Vulkan graphics pipeline is essentially the same as OpenGL’s. Therefore,
learning OpenGL is progress toward Vulkan. Moreover, once a programmer has
mastered OpenGL, she has most of what’s needed to “take full charge” of the
pipeline, which is what Vulkan is all about.
(b) The runtime gains of Vulkan don’t begin to show up in any significant way
until one gets to complex scenes with lots of textures, objects and animation.
Less complicated applications - including, obviously, those in any introductory
CG book - benefit little performance-wise from being written (or, rewritten) in
Vulkan, not justifying the huge overhead in code.
This means that many OpenGL apps are going to stay that way and new ones
continue to be written. It’s a matter of knowing which tool to use: pre-shader xxi
Preface OpenGL, OpenGL 4.x, Vulkan, . . .. (Hooking up a U-Haul trailer to the back of
a Ferrari is never a good idea.)

Nevertheless, if you are of the Vulkan or bust frame of mind then the advice we would
have is to study this book up to Chapter 16, when you will have a solid understanding
of fourth-generation OpenGL, then pick up, say, the canonical Vulkan guide [131],
through which you should then be able to make quick progress.

Capsule Chapter Descriptions


Part I: Hello World
Chapter 1: An Invitation to Computer Graphics
A non-technical introduction to the field of computer graphics.
Chapter 2: On to OpenGL and 3D Computer Graphics
Begins the technical part of the book. It introduces OpenGL and fundamental
principles of 3D CG.

Part II: Tricks of the Trade


Chapter 3: An OpenGL Toolbox
Describes a collection of OpenGL programming devices, including vertex arrays, vertex
buffer and array objects, mouse and key interaction, pop-up menus, and several more.

Part III: Movers and Shapers


Chapter 4: Transformation, Animation and Viewing
Introduces the theory and programming of animation and the virtual camera. Explains
user interactivity via object selection. Foundational chapter for game and movie
programming.
Chapter 5: Inside Animation: The Theory of Transformations
Presents the mathematical theory behind animation, particularly linear and affine
transformations in 3D.
Chapter 6: Advanced Animation Techniques
Describes frustum culling, occlusion culling as well as orienting animation using both
Euler angles and quaternions, techniques essential to programming games and busy
scenes.

Part IV: Geometry for the Home Office


Chapter 7: Convexity and Interpolation
Explains the theory of convexity and the role it plays in interpolation, which is the
procedure of spreading material properties from the vertices of a primitive to its
interior.
Chapter 8: Triangulation
Describes how and why complex objects should be split into triangles for efficient
rendering.
Chapter 9: Orientation
Describes how the orientation of a primitive is used to determine the side of it that
the camera sees, and the importance of consistently orienting a collection of primitives
making up a single object.

Part V: Making Things Up


xxii Chapter 10: Modeling in 3D Space
Systematizes the principles of modeling both curves and surfaces, including Bézier and Preface
fractal. Shows how to import objects from external design environments. Foundational
chapter for object design.

Part VI: Lights, Camera, Equation


Chapter 11: Color and Light
Explains the theory of light and material color, the interaction between the two, and
describes how to program light and color in 3D scenes. Foundational chapter for scene
design.
Chapter 12: Textures
Explains the theory of texturing and how to apply textures to objects and render to a
texture.
Chapter 13: Special Visual Techniques
Describes a set of special techniques to enhance the visual quality of a scene,
including, among others, blending, billboarding, stencil buffer methods, image and
pixel manipulation, cube mapping a skybox, and shadow mapping.

Part VII: Pixels, Pixels, Everywhere


Chapter 14: Raster Algorithms
Describes low-level rendering algorithms to determine the set of pixels on the screen
corresponding to a line or a polygon.

Part VIII: Programming Pipe Dreams


Chapter 15: OpenGL 4.3, Shaders and the Programmable Pipeline: Liftoff
Introduces 4th generation OpenGL and GLSL (OpenGL Shading Language) and how
to vertex and fragments shaders to program the pipeline, particularly to animate,
light and apply textures.
Chapter 16: OpenGL 4.3, Shaders and the Programmable Pipeline: Escape Velocity
Continuing onto advanced 4th generation OpenGL topics, including, among others,
instanced rendering, shader subroutines, transform feedback, particle systems, as well
as tessellation and geometry shaders.

Part IX: Anatomy of Curves and Surfaces


Chapter 17: Bézier
Describes the theory and programming of Bézier primitives, including curves and
surfaces.
Chapter 18: B-Spline
Describes the theory and programming of (polynomial) B-spline primitives, including
curves and surfaces.
Chapter 19: Hermite
Introduces the basics of Hermite curves and surfaces.

Part X: Well Projected


Chapter 20: Applications of Projective Spaces: Projection Transformations and
Rational Curves
Applies the theory of projective spaces to deduce the projection transformation in
the graphics pipeline. Introduces rational Bézier and B-spline, particularly NURBS,
theory and practice.

Part XI: Time for a Pipe


Chapter 21: Pipeline Operation xxiii
Preface Gives a detailed view of the synthetic-camera and ray-tracing pipelines and introduces
radiosity.

Appendix A: Projective Spaces and Transformations


A CG-oriented introduction to the mathematics of projective spaces and transforma-
tions. Provides a complete theoretical background for Chapter 20 on applications of
projective spaces.

Appendix B: Math Self-Test


A self-test to assess math readiness for intending readers.

Appendix C: Math Self-Test Solutions


Solutions for the math self-test.

Chapter 1 Chapter 2
An Invitation On to OpenGL
to Computer and 3D Computer
Graphics Graphics

Chapter 3 Chapter 4 Chapter 7 Chapter 14


An OpenGL Transformation, Convexity and Raster
Toolbox Animation and Interpolation Algorithms
Viewing

Chapter 5 Chapter 6 Chapter 8


Inside Animation: Advanced
The Theory of Animation Triangulation
Transformations Techniques

Chapter 9

Orientation

Chapter 10
Modeling in
3D Space

Chapter 11 Chapter 17 Appendix A


Projective
Color and Light Bézier Spaces and
Transformations

Chapter 12 Chapter 18 Chapter 21


Texture B-Spline Pipeline
Operation

Chapter 13 Chapter 19 Chapter 20


Special Visual Applications of
Hermite Projective
Techniques Spaces: ...

Chapter 15
OpenGL 4.3,
Shaders ... :
Liftoff

Chapter 16
OpenGL 4.3,
Shaders ... :
Escape Velocity

Figure 2: Chapter dependence chart: dashed arrows represent weak dependencies.

xxiv
Suggested Course Outlines Preface
See the chapter dependencies in Figure 2.
(1) Undergraduate one-semester first CG course:
This course should be based on Chapters 1-16, though full coverage might be
ambitious for one semester. Instructors may pick topics to emphasize or skip,
depending on their goals for the course and the chapter dependence chart.
For example, for more practice and less theory, a possible sequence would be 1 →
2 → 3 → 4 → 6 (only frustum culling) → 7 → 8 → 9 → 10 (skip curve/surface
theory) → 11 → 12 → 13 → 15 → 16.
Even this abbreviated sequence may be hard to pack into one semester. Please
keep in mind that when choosing what to write about the author preferred to
err on the side of excess rather than less. So, almost always will the instructor
find more material in a chapter than she cares to teach – we leave her to pick
her way out.
The most effective teaching method with this book is to base discussion around
experiments – both from the book and those the instructor develops herself.
Our Experimenter software makes this especially convenient. Students should be
involved in the experiments, running code simultaneously on their own machines
in class. Use of slides should be minimized except, possibly, for the plentiful
book figures, which are available to download, arranged as one PowerPoint
presentation per chapter.
(2) Advanced CG courses:
This book could serve as a reference for a study of 3D design – particularly,
Bézier (Chapter 17), B-spline (Chapter 18) and rational Bézier and NURBS
theory (Chapter 20) – and of projective transformations and their applications
(Appendix A and Chapter 20). From a practical point of view, Chapters 15-16
go fairly deep into the fourth generation of OpenGL and the GLSL, useful for
students who may be familiar with only the classical pipeline.
(3) Self-study:
A recommended first pass would be 1 → 2 → 3 → 4 → 7 → 8 → 9 (go light on
7-9 if your math is rusty) → 10 (skip theory) → 11 → 12 → 13 → 15 → 16.
Following this the student should take up a fair-sized programming project,
returning to the book as needed. For the theoretically-inclined there’s a lot to
keep her busy in Chapters 5 and 17-21.

Acknowledgments
I owe a lot to many people, most of all students whom I have had the privilege of
teaching in my CG classes over the years at UW-Milwaukee and then the Asian
Institute of Technology.
I thank KV, Ichiro Suzuki, Glenn Wardius, Mahesh Kumar, Le Phu Binh, Maria
Sell and, especially, Paul McNally, for their support at UWM, where I began to teach
CG and learn OpenGL.
I am grateful to my colleagues and the staff and students at AIT for such a pleasant
environment, which allowed me to combine teaching and research commitments with
the writing of a book.
Particular thanks at AIT to Vu Dinh Van, Nguyen Duc Cong Song, Ahmed
Waliullah Kazi, Hameedullah Kazi, Long Hoang, Songphon Klabwong, Robin Chanda,
Sutipong Kiatpanichgij, Samitha Kumara, Somchok Sakjiraphong, Pyae Phyo Myint
Soe, Adbulrahman Otman, Sushanta Paudyal, Akila de Silva, Nitchanun Saksinchai,
Thee Thet Zun, Suwanna Xanthavanij, Visutr Boonnateephisit, Matt Dailey, and our
ever-helpful secretaries K. Siriporn and K. Tong. xxv
Preface I am grateful to Kumpee Teeravech, Kanit Tangkathach, Thanapoom Veeranitinun,
Pongpon Nilaphruek, and Wuttinan Sereethavekul, students of my CG course at AIT,
for allowing me to use programs they wrote.
I owe an enormous debt of gratitude to my former student Chansophea Chuon for
hundreds of hours of help with the first edition, which got this book off the ground in
the first place. I thank Somying Pongpimol for her brilliant Illustrator drawings. She
drew several of the figures based on my rather amateurish original Xfig sketches. I
would like to thank Olivier Nicole for help with the book’s website.
I am especially grateful to Brian Barsky for encouraging me to persevere after
seeing an early and awkward draft of the first edition, and subsequently inviting the
finished product to the series he was then editing. Relatedly, I thank my neighbor
Doug Cooper two floors down for putting me in touch with Brian at the time Brian
was scouting prospective authors.
I want to acknowledge the production team at Taylor & Francis who went out of
their way for this book. Particularly, I want to thank my editor Randi Cohen who is
as professional and efficient as she is pleasant to deal with.
I am grateful to readers of the first and second editions, as well as reviewers
who looked over drafts and proposals, whose comments led, hopefully, to significant
improvements.
I have nothing but praise for the DJs and kindly staff of the Mixx nightclub in
downtown Bangkok whose dance floor provided a much-needed sanctuary for me to
blow off steam after long hours on the computer.
I acknowledge the many persons and businesses who were kind enough to allow
me to include images to which they own copyrights.
On a personal note, I express my deep gratitude to Dr. Anupam De for keeping
Kamaladi healthy enough that I could concentrate on the first edition through the
few years that I spent writing it.
Finally, I must say that had I not had the opportunity to study computer science
in the United States and teach there, I would never have reached a position where I
could even contemplate writing a textbook. It’s true, too, that had I not moved to
Thailand, this book would never have begun to be written. This is an enchanting
country with a strangely liberating and lightening effect – to which thousands of
expats can attest – that encourages one to express oneself.

Website and Contact Information


The book’s website is at www.sumantaguha.com. Users of the book will find there
various resources including downloads. The author welcomes feedback, corrections
and suggestions for improvement emailed to him at sg@sumantaguha.com.

xxvi
About the Author

Sumanta Guha earned a Ph.D. in mathematics from the Indian Statistical Institute,
Kolkata, in 1987. From 1984 to 1987 he taught mathematics at Jadavpur University
in Kolkata. He left in 1987 to study computer science at the University of Michigan
in Ann Arbor, where he earned a Ph.D. in 1991. On graduating from Michigan he
joined the Electrical Engineering and Computer Science faculty of the University of
Wisconsin-Milwaukee where he taught from 1991 to 2002. In 2002 he moved to the
Computer Science and Information Management program of the Asian Institute of
Technology in Thailand, where he is currently an adjunct professor. His research
interests include computational geometry, computer graphics, computational topology,
robotics and data mining.

xxvii
Other documents randomly have
different content
THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like