Where can buy Computer graphics programming in opengl using c++, third edition gordon phd ebook with

Page 1


Computer

Visit to download the full and correct content document: https://textbookfull.com/product/computer-graphics-programming-in-opengl-using-c-th ird-edition-gordon-phd/

More products digital (pdf, epub, mobi) instant download maybe you interests ...

Computer Graphics Programming in OpenGL with Java

Gordon

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

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

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

Computer graphics through openGL Third Edition Guha

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

Primary Mathematics Textbook 2B Jennifer Hoerst

https://textbookfull.com/product/primary-mathematicstextbook-2b-jennifer-hoerst/

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-modernopengl-graphics-programming-in-a-step-by-step-fashion-1stedition-joey-de-vries/

Computer Graphics Through OpenGL: From Theory to Experiments Sumanta Guha

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

Introduction to Computer Graphics with OpenGL ES First Edition Junghyun Han

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

Handbook of Macroeconomics, Volume 2A-2B SET 1st Edition John B. Taylor

https://textbookfull.com/product/handbook-of-macroeconomicsvolume-2a-2b-set-1st-edition-john-b-taylor/

Programming Principles and Practice Using C Third Edition Bjarne Stroustrup

https://textbookfull.com/product/programming-principles-andpractice-using-c-third-edition-bjarne-stroustrup/

COMPUTER GRAPHICS

PROGRAMMING IN OPENGL WITH C++

ThirdEdition

LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY

By purchasing or using this book and its companion files (the “Work”), you agree that this license grants permission to use the contents contained herein, including the companion files, but does not give you the right of ownership to any of the textual content in the book / files or ownership to any of the information or products contained in it. ThislicensedoesnotpermituploadingoftheWorkonto theInternet or on a network (of any kind) without the written consent of the Publisher. Duplication or dissemination of any text, code, simulations, images, etc. contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the Publisher or the owner of the content, etc., in order to reproduce or network any portion of the textual material (in any media) that is contained in the Work.

MERCURY LEARNING AND INFORMATION (“MLI” or “the Publisher”) and anyone involved in the creation, writing, or production of the companion files, accompanying algorithms, code, or computer programs (“the software”), and any accompanying Web site or software of the Work, cannot and do not warrant the performance or results that might be obtained by using the contents of the Work. The author, developers, and the Publisher have used their best efforts to insure the accuracy and functionality of the textual material and/or programs contained in this package; we, however, make no warranty

of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold “as is” without warranty (except for defective materials used in manufacturing the book or due to faulty workmanship).

The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and/or companion files, and only at the discretion of the Publisher. The use of “implied warranty” and certain “exclusions” varies from state to state and might not apply to the purchaser of this product.

The companion files are available for downloading by writing to the publisheratinfo@merclearning.com.

COMPUTER GRAPHICS

PROGRAMMING IN OPENGL WITH C++

ThirdEdition

CaliforniaStateUniversity,Sacramento

John

CaliforniaStateUniversity,Sacramento

MERCURY LEARNING AND INFORMATION

Boston, Massachusetts

Copyright ©2021 by MERCURY LEARNING AND INFORMATION. An imprint of DeGruyter Inc. All rights reserved.

Thispublication,portionsofit,oranyaccompanyingsoftwaremaynot bereproducedinanyway,storedinaretrievalsystemofanytype,or transmittedbyanymeans,media,electronicdisplayormechanical display,including,butnotlimitedto,photocopy,recording,Internet postings,orscanning,withoutpriorpermissioninwritingfromthe publisher .

Publisher: David Pallai

MERCURY LEARNING AND INFORMATION

121 High Street Boston, MA 02110 info@merclearning.com www.merclearning.com (800) 232-0223

ComputerGraphicsProgramminginOpenGLwithC++,ThirdEdition. V. Scott Gordon & John Clevenger.

ISBN: 978-1-50152-259-8

The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any

omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others.

Library of Congress Control Number: 2023951965

242526321    Printed on acid-free paper in the United States of America.

Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 800-232-0223 (toll free). Digital versions of our titles are available at: www.academiccourseware.com and other e-vendors. Allcompanionfilesareavailablebywritingto thepublisheratinfo@merclearning.com.

The sole obligation of MERCURY LEARNING AND INFORMATION to the purchaser is to replace the book and/or files, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.

Contents

Preface

What’sNewinthisEdition

IntendedAudience

HowtoUseThisBook

Acknowledgments

AbouttheAuthors

Chapter 1 Getting Started

1.1 Languages and Libraries

1.1.1 C++

1.1.2 OpenGL / GLSL

1.1.3 Window Management

1.1.4 Extension Library

1.1.5 Math Library

1.1.6 Texture Management

1.1.7 Optional Libraries

1.2 Installation and Configuration

Chapter 2 The OpenGL Pipeline

2.1 The OpenGL Pipeline

2.1.1 C++/OpenGL Application

2.1.2 Vertex and Fragment Shaders

2.1.3 Tessellation

2.1.4 Geometry Shader

2.1.5 Rasterization

2.1.6 Fragment Shader

2.1.7 Pixel Operations

2.2 Detecting OpenGL and GLSL Errors

2.3 Reading GLSL Source Code from Files

2.4 Building Objects from Vertices

2.5 Animating a Scene

2.6 Organizing the C++ Code Files

Chapter 3 Mathematical Foundations

3.1 3D Coordinate Systems

3.2 Points

3.3 Matrices

3.4 Transformation Matrices

3.4.1 Translation

3.4.2 Scaling

3.4.3 Rotation

3.5 Vectors

3.5.1 Uses for DotProduct

3.5.2 Uses for CrossProduct

3.6 Local and World Space

3.7 Eye Space and the Synthetic Camera

3.8 Projection Matrices

3.8.1 The Perspective Projection Matrix

3.8.2 The Orthographic Projection Matrix

3.9 Look-At Matrix

3.10 GLSL Functions for Building Matrix Transforms

Chapter 4 Managing 3D Graphics Data

4.1 Buffers and Vertex Attributes

4.2 Uniform Variables

4.3 Interpolation of Vertex Attributes

4.4 Model-View and Perspective Matrices

4.5 Our First 3D Program – a 3D Cube

4.6 Rendering Multiple Copies of an Object

4.6.1 Instancing

4.7 Rendering Multiple Different Models in a Scene

4.8 Matrix Stacks

4.9 Combating “Z-Fighting” Artifacts

4.10 Other Options for Primitives

4.11 Coding for Performance

4.11.1 Minimizing Dynamic Memory Allocation

4.11.2 Pre-Computing the Perspective Matrix

4.11.3 Back-Face Culling

Chapter 5 Texture Mapping

5.1 Loading Texture Image Files

5.2 Texture Coordinates

5.3 Creating a Texture Object

5.4 Constructing Texture Coordinates

5.5 Loading Texture Coordinates into Buffers

5.6 Using the Texture in a Shader: Sampler Variables and Texture Units

5.7 Texture Mapping: Example Program

5.8 Mipmapping

5.9 Anisotropic Filtering

5.10 Wrapping and Tiling

5.11 Perspective Distortion

5.12 Textures – Additional OpenGL Details

Chapter 6 3D Models

6.1 Procedural Models – Building a Sphere

6.2 OpenGL Indexing – Building a Torus

6.2.1 The Torus

6.2.2 Indexing in OpenGL

6.3 Loading Externally Produced Models

Chapter 7 Lighting

7.1 Lighting Models

7.2 Lights

7.3 Materials

7.4 ADS Lighting Computations

7.5 Implementing ADS Lighting

7.5.1 Gouraud Shading

7.5.2 Phong Shading

7.6 Combining Lighting and Textures

Chapter 8 Shadows

8.1 The Importance of Shadows

8.2 Projective Shadows

8.3 Shadow Volumes

8.4 Shadow Mapping

8.4.1 Shadow Mapping (PASS ONE) – “Draw” Objects from Light Position

8.4.2 Shadow Mapping (Intermediate Step) – Copying the Z-Buffer to a Texture

8.4.3 Shadow Mapping (PASS TWO) – Rendering the Scene with Shadows

8.5 A Shadow Mapping Example

8.6 Shadow Mapping Artifacts

8.7 Soft Shadows

8.7.1 Soft Shadows in the Real World

8.7.2 Generating Soft Shadows – Percentage Closer Filtering (PCF)

8.7.3 A Soft Shadow/PCF Program

Chapter 9 Sky and Backgrounds

9.1 Skyboxes

9.2 Skydomes

9.3 Implementing a Skybox

9.3.1 Building a Skybox from Scratch

9.3.2 Using OpenGL Cube Maps

9.4 Environment Mapping

Chapter 10 Enhancing Surface Detail

10.1 Bump Mapping

10.2 Normal Mapping

10.3 Height Mapping

Chapter 11 Parametric Surfaces

11.1 Quadratic Bézier Curves

11.2 Cubic Bézier Curves

11.3 Quadratic Bézier Surfaces

11.4 Cubic Bézier Surfaces

Chapter 12 Tessellation

12.1 Tessellation in OpenGL

12.2 Tessellation for Bézier Surfaces

12.3 Tessellation for Terrain / Height Maps

12.4 Controlling Level of Detail (LOD)

Chapter 13 Geometry Shaders

13.1 Per-Primitive Processing in OpenGL

13.2 Altering Primitives

13.3 Deleting Primitives

13.4 Adding Primitives

13.5 Changing Primitive Types

Chapter 14 Other Techniques

14.1 Fog

14.2 Compositing / Blending / Transparency

14.3 User-Defined Clipping Planes

14.4 3D Textures

14.5 Noise

14.6 Noise Application – Marble

14.7 Noise Application – Wood

14.8 Noise Application – Clouds

14.9 Noise Application – SpecialEffects

Chapter 15 Simulating Water

15.1 Pool Surface and Floor Geometry Setup

15.2 Adding Surface Reflection and Refraction

15.3 Adding Surface Waves

15.4 Additional Corrections

15.5 Animating the Water Movement

15.6 Underwater Caustics

Chapter 16 Ray Tracing and Compute Shaders

16.1 Compute Shaders

16.1.1 Compiling and Using Compute Shaders

16.1.2 Parallel Computing in Compute Shaders

16.1.3 Work Groups

16.1.4 Work Group Details

16.1.5 Work Group Limitations

16.2 Ray Casting

16.2.1 Defining the 2D Texture Image

16.2.2 Building and Displaying the Ray Cast Image

16.2.3 Ray-Sphere Intersection

16.2.4 Axis-Aligned Ray-Box Intersection

16.2.5 Output of Simple Ray Casting Without Lighting

16.2.6 Adding ADS Lighting

16.2.7 Adding Shadows

16.2.8 Non-Axis-Aligned Ray-Box Intersection

16.2.9 Determining Texture Coordinates

16.2.10 Plane Intersection and Procedural Textures

16.3 Ray Tracing

16.3.1 Reflection

16.3.2 Refraction

16.3.3 Combining Reflection, Refraction, and Textures

16.3.4 Increasing the Number of Rays

16.3.5 Generalizing the Solution

16.3.6 Additional Examples

16.3.7 Blending Colors for Transparent Objects

Chapter 17 Ray Tracing of Complex Models

17.1 Ray-Triangle Intersection

17.1.1 Mathematics for Ray-Triangle Intersection

17.1.2 Implementing Ray-Triangle Intersection

17.1.3 Ray Tracing Multiple Triangles

17.2 Ray Tracing an OBJ Model

17.2.1 OBJ Loading for Ray Tracing C++ side

17.2.2 OBJ Loading for Ray Tracing GLSL side

17.3 Ray Tracing Multiple OBJ Models

17.4 Bounding Volume Hierarchies (BVH)

17.4.1 Implementing a BVH – C++ Side

17.4.2 Transferring the BVH to the Compute Shader

17.4.3 Ray-BVH Collision Testing

17.4.4 Performance Comparison

Chapter 18 Stereoscopy for 3D Glasses and VR Headsets

18.1 View and Projection Matrices for Two Eyes

18.2 Anaglyph Rendering

18.3 Side-by-Side Rendering

18.4 Correcting Lens Distortion in Headsets

18.5 A Simple Testing Hardware Configuration

Appendix A Installation and Setup for PC (Windows)

Appendix B Installation and Setup for Macintosh

Appendix C Using the Nsight Graphics Debugger

Appendix D Building a Simple Camera Controller

Index

Preface

This updated edition is designed primarily as a textbook for a typical computer science undergraduate course in OpenGL 3D graphics programming. However, we have also endeavored to create a text that could be used to teach oneself, without an accompanying course. With both of those aims in mind, we have tried to explain things as clearly and as simply as we can. All of the programming examples are stripped down and simplified as much as possible, but they are still complete so that the reader may run them all as presented.

One of the things that we hope is unique about this book is that we have strived to make it accessible to someone new to 3D graphics programming. While there is by no means a lack of information available on the topic—quite the contrary—many students are initially overwhelmed. This text is our attempt to write the book we wish we had had when we were starting out, with step-by-step explanations of the basics, progressing in an organized manner up through advanced topics. We considered titling the book “shader programming made easy”; however, we don’t think that there really is any way of making shader programming “easy.” We hope that we have come close.

This book teaches OpenGL programming in C++. There are several advantages to learning graphics programming in C++:

• OpenGL’s native language is C, so a C++ program can make direct OpenGL function calls.

• OpenGL applications written in C++ typically exhibit very high performance.

• C++ offers modern programming constructs (classes, polymorphism, etc.) not available in C.

• C++ is a popular language choice for using OpenGL, and a large number of instructional resources for OpenGL are available in C++.

It is worth mentioning that there do exist other language bindings for OpenGL. Popular alternatives exist for Java, C#, Python, and many others. This textbook focuses only on C++.

Another thing that makes this book unique is that it has a “sister” textbook: ComputerGraphicsProgramminginOpenGLWithJava. The two books are organized in lockstep, with the same chapter and section numbers and topics, figures, exercises, and theoretical descriptions. Wherever possible, the code is organized similarly. Of course, the use of C++ versus Java leads to considerable programming differences (although all of the shader code is identical). Still, we believe that we have provided virtually identical learning paths, even allowing a student to choose either option within a single classroom.

An important point of clarification is that there exist both different versions of OpenGL (briefly discussed later) and different variants of OpenGL. For example, in addition to “standard OpenGL” (sometimes called “desktop OpenGL”), there exists a variant called “OpenGL ES,” which is tailored for development of embedded systems (hence the “ES”). “Embedded systems” include devices such as mobile phones, game consoles, automobiles, and industrial control systems. OpenGL ES is mostly a subset of standard OpenGL, eliminating a large number of operations that are typically not needed for embedded systems. OpenGL ES also adds some additional functionality, typically application-specific operations for particular target environments. This book focuses on standard OpenGL.

Yet another variant of OpenGL is called “WebGL.” Based on OpenGL ES, WebGL is designed to support the use of OpenGL in web browsers. WebGL allows an application to use JavaScript1 to invoke OpenGL ES operations, which makes it easy to embed OpenGL graphics into standard HTML (web) documents. Most modern web browsers support WebGL, including Apple Safari, Google Chrome, Microsoft Edge, Microsoft Internet Explorer, Mozilla Firefox, and Opera. Since web programming is outside the scope of this book, we will not cover any WebGL specifics. Note however that because WebGL is based on OpenGL ES, which in turn is based on standard OpenGL, much of what is covered in this book can be transferred directly to learning about these OpenGL variants.

The very topic of 3D graphics lends itself to impressive, even beautiful images. Indeed, many popular textbooks on the topic are filled with breathtaking scenes, and it is enticing to leaf through their galleries. While we acknowledge the motivational utility of such examples, our aim is to teach, not to impress. The images in this book are simply the outputs of the example programs, and since this is an introductory text, the resulting scenes are unlikely to impress an expert. However, the techniques presented do constitute the foundational elements for producing today’s stunning 3D effects.

We also have not tried tried to create an OpenGL “reference.” Our coverage of OpenGL represents only a tiny fraction of its capabilities. Rather, our aim is to use OpenGL as a vehicle for teaching the fundamentals of modern shader-based 3D graphics programming, and provide the reader with a sufficiently deep understanding for further study.

What’sNewinThisEdition

There are two major additions in this 3rd edition of ComputerGraphics ProgramminginOpenGLUsingC++:

• Chapter 17 – RayTracingofComplexModels

• Appendix D – BuildingaSimpleCameraController

Ray Tracing is a hot topic in computer graphics, and Chapter 17 expands on our coverage to include: (1) ray tracing models stored in

OBJ files, and (2) using bounding volume hierarchies to improve performance and make the ray tracing of complex models feasible. We are excited to finally be able to include this important material in our book.

Appendix D addresses the most common difficulty students have reported when using our book – moving the virtual camera around a 3D scene. In earlier editions, we purposely avoided including code for controlling the camera because writing a camera controller is an excellent instructional exercise for students. Instead, we had described the basic elements and mathematical formulas for doing this (in Chapter 3), leaving the implementation as an exercise. It turned out that for most of our students, this was not enough, and so we have been providing our own students with supplemental material describing, step by step, how to implement a camera controller. This new material is now included in the book as Appendix D. Although we still have avoided providing fully implemented code for this task, we think that the new appendix will give all students the information they need to complete the task without confusion.

We overhauled our coverage of refractionin Chapter 16, expanding both the explanation and the examples. We think that the reader will find our revised examples of refraction to be more comprehensive and more realistic.

Stereoscopy, which was Chapter 17 in the 2nd edition, has become Chapter 18 in this 3rd edition.

Besides the new material, there are important revisions throughout the book. A small but important correction that we made was to change all of our lighting computations so that they are done in world space rather than camera space – this makes it easier to build applications that require being able to move the camera around. We had previously made this lighting computation change in our “sister” Java book, and implementing the same changes in this C++ book aligns the two volumes so that all of their shaders are now identical.

We beefed up our installation instructions (Appendices A and B). Configuring the libraries remains more arduous than it really ought to be, but we have tried to explain it more thoroughly than we did in our previous edition. Macintosh support for OpenGL continues to worsen, making library installation even more difficult on that platform. We strove to list all of the steps as carefully as possible – as of November 2023, the steps we list in Appendix B worked correctly.

NVIDIA’s Nsight debugger, the topic of Appendix C, now has a standalone application that is easier to use than previous versions that required integration with Visual Studio. We revised Appendix C to utilize the newer standalone version.

There are dozens of small changes in every chapter that the reader might not even notice: fixing typos, cleaning up code inconsistencies, updating the installation instructions, making slight wording changes, sprucing up figures, updating references, and so on Great effort has been made to stay up to date and error free in a book about an ever-

changing technology. As a result, this 3rd edition is slightly larger than the previous edition.

IntendedAudience

This book is targeted at students of computer science. This could mean undergraduates pursuing a BS degree, but it could also mean anyone who studies computer science. As such, we are assuming that the reader has at least a solid background in object-oriented programming, at the level of someone who is, for example, a computer science major at the junior or senior level.

There are also some specific things that we use in this book that we don’t cover, because we assume the reader already has sufficient background in the following:

• C++ and its most commonly used libraries, such as the Standard Template Library;

• familiarity with using an Integrated Development Environment (IDE), such as Visual Studio;

• basic data structures and algorithms, such as linked lists, stacks and queues, and so on;

• recursion;

• event-driven programming concepts;

• basic matrix algebra and trigonometry;

• basic analytic geometry, such as for defining points, lines, vectors, planes, and circles, and

• awareness of color models, such as RGB, RGBA, and so on.

It is hoped that the potential audience for this new book is further bolstered by the existence of its “sister” textbook, ComputerGraphics Programming in OpenGL with Java. In particular, we envision a learning environment where students are free to utilize either C++ or Java inthesameclassroom, selecting one or the other book. The two texts cover the material sufficiently in lockstep that we have been able to conduct our graphics programming course successfully in this manner.

HowtoUseThisBook

This book is designed to be read from front to back. That is, material in later chapters frequently relies on information learned in earlier chapters. So it probably won’t work to jump back and forth in the chapters; rather, work your way forward through the material.

This is also intended mostly as a practical, hands-on guide. While there is plenty of theoretical material included, the reader should treat this text as a sort of “workbook,” in which you learn basic concepts by actually programming them yourself. We have provided code for all of the examples, but to really learn the concepts you will want to “play” with those examples—extend them to build your own 3D scenes.

At the end of each chapter are a few exercises to solve. Some are very simple, involving merely making small modifications to the provided code. The problems that are marked “(PROJECT),” however, are expected to take some time to solve, and require writing a significant amount of code, or combining techniques from various examples. There are also a few marked “(RESEARCH)”—those are problems that encourage independent study because this textbook doesn’t provide sufficient detail to solve them.

OpenGL calls often involve long lists of parameters. While writing this book, the authors debated whether or not to, in each case, describe all of the parameters. We decided that in the early chapters we would describe every detail. Further into the book, as the topics progress, we decided to avoid getting bogged down in every piece of minutiae in the OpenGL calls (and there are many), for fear of the reader losing sight of the big picture. For this reason, it is essential when working through the examples to have ready access to reference material for OpenGL and the various libraries being used.

For this, there are a number of excellent online resources that we recommend using in conjunction with this book. The documentation for OpenGL is absolutely essential; details on the various commands are available either by simply using Google to search for the command in question, or by visiting:

https://www.khronos.org/registry/OpenGL-Refpages/gl4/

Our examples utilize a mathematics library called GLM. After installing GLM (described in the appendices), the reader should locate the accompanying online documentation and bookmark it. At press time, the current link is:

https://glm.g-truc.net/0.9.9/index.html

Another library used throughout the book for which the reader may wish to periodically consult its documentation is SOIL2, which is used for loading and processing texture image files. Documentation for SOIL2, and the image loading library stb on which it is based, can be found on its repository:

https://github.com/SpartanJ/soil2

There are many other books on 3D graphics programming that we recommend reading in parallel with this book (such as for solving the “research” problems). Here are five that we often refer to:

• (Sellers et al.) OpenGLSuperBible[SW15]

• (Kessenich et al.) OpenGLProgrammingGuide[KS16] (the “red book”)

• (Wolff) OpenGL4ShadingLanguageCookbook[WO18]

• (Angel and Shreiner) InteractiveComputerGraphics[AS20]

• (Luna) Introduction to 3D Game Programming with DirectX 12 [LU16]

CompanionFiles

There is a set of companion files available for this book that contain the following items:

• All of the C++/OpenGL programs and related utility class files and GLSL shader code presented in the book

• The models and texture files used in the various programs and examples

• The cubemap and skydome image files used to make the skies and horizons

• Normal maps and height maps for lighting and surface detail effects

• All of the figures in the book, as image files

The companion files are available for downloading by writing to the publisher at info@merclearning.com.

InstructorAncillaries

Instructors in a college or university setting are encouraged to obtain the instructor ancillary package that is available for this book. It contains the following additional items:

• A complete set of PowerPoint slides covering all topics in the book

Another random document with no related content on Scribd:

The Project Gutenberg eBook of Elmer Gantry

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.

Title: Elmer Gantry

Author: Sinclair Lewis

Release date: January 3, 2024 [eBook #72609]

Language: English

Original publication: New York: Harcourt, Brace and Company, 1927

Credits: Al Haines, Mark Akrigg, Cindy Beyer & the online Distributed Proofreaders Canada team at http://www.pgdpcanada.net *** START OF THE PROJECT GUTENBERG EBOOK ELMER GANTRY ***

E L M E R G A N T R Y

Fourteenth printing, September, 1928

PRINTED IN THE U. S. A. BY QUINN & BODEN COMPANY, INC, RAHWAY, N. J.

To H. L. MENCKEN with profound

admiration

No character in this book is the portrait of any actual person

L M E R G A N T R Y

CHAPTER I I

was drunk. He was eloquently drunk, lovingly and pugnaciously drunk. He leaned against the bar of the Old Home Sample Room, the most gilded and urbane saloon in Cato, Missouri, and requested the bartender to join him in “The Good Old Summer Time,” the waltz of the day

Blowing on a glass, polishing it and glancing at Elmer through its flashing rotundity, the bartender remarked that he wasn’t much of a hand at this here singing business. But he smiled. No bartender could have done other than smile on Elmer, so inspired and full of gallantry and hell-raising was he, and so dominating was his beefy grin.

“All right, old socks,” agreed Elmer. “Me and my roommate’ll show you some singing as is singing! Meet roommate. Jim Lefferts. Bes’ roommate in world. Wouldn’t live with him if wasn’t! Bes’ quarterback in Milwest. Meet roommate.”

The bartender again met Mr. Lefferts, with protestations of distinguished pleasure.

Elmer and Jim Lefferts retired to a table to nourish the long, rich, chocolate strains suitable to drunken melody. Actually, they sang very well. Jim had a resolute tenor, and as to Elmer Gantry, even more than his bulk, his thick black hair, his venturesome black eyes, you remembered that arousing barytone. He was born to be a senator. He never said anything important, and he always said it sonorously. He could make “Good morning” seem profound as Kant, welcoming as a brass band, and uplifting as a cathedral organ. It was a ’cello, his voice, and in the enchantment of it you did not hear his slang, his boasting, his smut, and the dreadful violence which (at this period) he performed on singulars and plurals.

Luxuriously as a wayfarer drinking cool beer they caressed the phrases in linked sweetness long drawn out:

Strolling through the shaaaaady lanes, with your baby-mine, You hold her hand and she holds yours, and that’s a very good sign

That she’s your tootsey-wootsey in the good old summer time.

Elmer wept a little, and blubbered, “Lez go out and start a scrap. You’re lil squirt, Jim. You get somebody to pick on you, and I’ll come along and knock his block off. I’ll show ’em!” His voice flared up. He was furious at the wrong about to be suffered. He arched his paws with longing to grasp the non-existent scoundrel. “By God, I’ll knock the tar out of um! Nobody can touch my roommate! Know who I am? Elmer Gantry! Thash me! I’ll show um!”

The bartender was shuffling toward them, amiably ready for homicide.

“Shut up, Hell-cat. What you need is ’nother drink. I’ll get ’nother drink,” soothed Jim, and Elmer slid into tears, weeping over the ancient tragic sorrows of one whom he remembered as Jim Lefferts.

Instantly, by some tricky sort of magic, there were two glasses in front of him. He tasted one, and murmured foolishly, “ ’Scuse me.” It was the chaser, the water. But they couldn’t fool him! The whisky would certainly be in that other lil sawed-off glass. And it was. He was right, as always. With a smirk of self-admiration he sucked in the raw Bourbon. It tickled his throat and made him feel powerful, and at peace with every one save that fellow—he could not recall who, but it was some one whom he would shortly chastise, and after that float into an Elysium of benevolence.

The barroom was deliriously calming. The sour invigorating stench of beer made him feel healthy. The bar was one long shimmer of beauty—glowing mahogany, exquisite marble rail, dazzling glasses, curiously shaped bottles of unknown liqueurs, piled with a craftiness which made him very happy. The light was dim, completely soothing, coming through fantastic windows such as are found only in churches, saloons, jewelry shops, and other retreats from reality. On the brown plaster walls were sleek naked girls.

He turned from them. He was empty now of desire for women.

“That damn’ Juanita. Jus’ wants to get all she can out of you. That’s all,” he grumbled.

But there was an interesting affair beside him. A piece of newspaper sprang up, apparently by itself, and slid along the floor That was a very funny incident, and he laughed greatly.

He was conscious of a voice which he had been hearing for centuries, echoing from a distant point of light and flashing through ever-widening corridors of a dream.

“We’ll get kicked out of here, Hell-cat. Come on!”

He floated up. It was exquisite. His legs moved by themselves, without effort. They did a comic thing once—they got twisted and the right leg leaped in front of the left when, so far as he could make out, it should have been behind. He laughed, and rested against some one’s arm, an arm with no body attached to it, which had come out of the Ewigkeit to assist him.

Then unknown invisible blocks, miles of them, his head clearing, and he made grave announcement to a Jim Lefferts who suddenly seemed to be with him:

“I gotta lick that fellow.”

“All right, all right. You might as well go find a nice little fight and get it out of your system!”

Elmer was astonished; he was grieved. His mouth hung open and he drooled with sorrow. But still, he was to be allowed one charming fight, and he revived as he staggered industriously in search of it.

Oh, he exulted, it was a great party. For the first time in weeks he was relieved from the boredom of Terwillinger College.

II

Elmer Gantry, best known to classmates as Hell-cat, had, this autumn of 1902, been football captain and led the best team Terwillinger College had known in ten years. They had won the championship of the East-middle Kansas Conference, which consisted of ten denominational colleges, all of them with buildings

and presidents and chapel services and yells and colors and a standard of scholarship equal to the best high-schools. But since the last night of the football season, with the glorious bonfire in which the young gentlemen had burned up nine tar barrels, the sign of the Jew tailor, and the president’s tabby-cat, Elmer had been tortured by boredom.

He regarded basket-ball and gymnasium antics as light-minded for a football gladiator. When he had come to college, he had supposed he would pick up learnings of cash-value to a lawyer or doctor or insurance man—he had not known which he would become, and in his senior year, aged twenty-two this November, he still was doubtful. But this belief he found fallacious. What good would it be in the courtroom, or at the operating table, to understand trigonometry, or to know (as last spring, up to the examination on European History, he remembered having known) the date of Charlemagne? How much cash would it bring in to quote all that stuff —what the dickens was it now?—all that rot about “The world is too much around us, early and soon” from that old fool Wordsworth?

Punk, that’s what it was. Better be out in business. But still, if his mother claimed she was doing so well with her millinery business and wanted him to be a college graduate, he’d stick by it. Lot easier than pitching hay or carrying two-by-fours anyway.

Despite his invaluable voice, Elmer had not gone out for debating, because of the irritating library-grinding, nor had he taken to prayer and moral eloquence in the Y. M. C. A., for with all the force of his simple and valiant nature he detested piety and admired drunkenness and profanity.

Once or twice in the class in Public Speaking, when he had repeated the splendors of other great thinkers, Dan’l Webster and Henry Ward Beecher and Chauncey M. Depew, he had known the intoxication of holding an audience with his voice as with his closed hand, holding it, shaking it, lifting it. The debating set urged him to join them, but they were rabbit-faced and spectacled young men, and he viewed as obscene the notion of digging statistics about immigration and the products of San Domingo out of dusty spotted books in the dusty spotted library

He kept from flunking only because Jim Lefferts drove him to his books.

Jim was less bored by college. He had a relish for the flavor of scholarship. He liked to know things about people dead these thousand years, and he liked doing canned miracles in chemistry. Elmer was astounded that so capable a drinker, a man so deft at “handing a girl a swell spiel and getting her going” should find entertainment in Roman chariots and the unenterprising amours of sweet-peas. But himself—no. Not on your life. He’d get out and finish law school and never open another book—kid the juries along and hire some old coot to do the briefs.

To keep him from absolutely breaking under the burden of hearing the professors squeak, he did have the joy of loafing with Jim, illegally smoking the while; he did have researches into the lovability of co-eds and the baker’s daughter; he did revere becoming drunk and world-striding. But he could not afford liquor very often and the co-eds were mostly ugly and earnest.

It was lamentable to see this broad young man, who would have been so happy in the prize-ring, the fish-market, or the stock exchange, poking through the cobwebbed corridors of Terwillinger.

III

Terwillinger College, founded and preserved by the more zealous Baptists, is on the outskirts of Gritzmacher Springs, Kansas. (The springs have dried up and the Gritzmachers have gone to Los Angeles, to sell bungalows and delicatessen.) It huddles on the prairie, which is storm-racked in winter, frying and dusty in summer, lovely only in the grass-rustling spring or drowsy autumn.

You would not be likely to mistake Terwillinger College for an Old Folks’ Home, because on the campus is a large rock painted with class numerals.

Most of the faculty are ex-ministers.

There is a men’s dormitory, but Elmer Gantry and Jim Lefferts lived together in the town, in a mansion once the pride of the Gritzmachers themselves: a square brick bulk with a white cupola.

Their room was unchanged from the days of the original August Gritzmacher; a room heavy with a vast bed of carved black walnut, thick and perpetually dusty brocade curtains, and black walnut chairs hung with scarves that dangled gilt balls. The windows were hard to open. There was about the place the anxious propriety and all the dead hopes of a secondhand furniture shop.

In this museum, Jim had a surprising and vigorous youthfulness. There was a hint of future flabbiness in Elmer’s bulk, but there would never be anything flabby about Jim Lefferts. He was slim, six inches shorter than Elmer, but hard as ivory and as sleek. Though he came from a prairie village, Jim had fastidiousness, a natural elegance. All the items of his wardrobe, the “ordinary suit,” distinctly glossy at the elbows, and the dark-brown “best suit,” were ready-made, with faltering buttons, and seams that betrayed rough ends of thread, but on him they were graceful. You felt that he would belong to any set in the world which he sufficiently admired. There was a romantic flare to his upturned overcoat collar; the darned bottoms of his trousers did not suggest poverty but a careless and amused ease; and his thoroughly commonplace ties hinted of clubs and regiments.

His thin face was resolute. You saw only its youthful freshness first, then behind the brightness a taut determination, and his brown eyes were amiably scornful.

Jim Lefferts was Elmer’s only friend; the only authentic friend he had ever had.

Though Elmer was the athletic idol of the college, though his occult passion, his heavy good looks, caused the college girls to breathe quickly, though his manly laughter was as fetching as his resonant speech, Elmer was never really liked. He was supposed to be the most popular man in college; every one believed that every one else adored him; and none of them wanted to be with him. They were all a bit afraid, a bit uncomfortable, and more than a bit resentful.

It was not merely that he was a shouter, a pounder on backs, an overwhelming force, so that there was never any refuge of intimacy with him. It was because he was always demanding. Except with his widow mother, whom he vaguely worshiped, and with Jim Lefferts,

Elmer assumed that he was the center of the universe and that the rest of the system was valuable only as it afforded him help and pleasure.

He wanted everything.

His first year, as the only Freshman who was playing on the college football team, as a large and smiling man who was expected to become a favorite, he was elected president. In that office, he was not much beloved. At class-meetings he cut speakers short, gave the floor only to pretty girls and lads who toadied to him, and roared in the midst of the weightiest debates, “Aw, come on, cut out this chewing the rag and let’s get down to business!” He collected the class-fund by demanding subscriptions as arbitrarily as a Catholic priest assessing his parishioners for a new church.

“He’ll never hold any office again, not if I can help it!” muttered one Eddie Fislinger, who, though he was a meager and rusty-haired youth with protruding teeth and an uneasy titter, had attained power in the class by always being present at everything, and by the piety and impressive intimacy of his prayers in the Y. M. C. A.

There was a custom that the manager of the Athletic Association should not be a member of any team. Elmer forced himself into the managership in Junior year by threatening not to play football if he were not elected. He appointed Jim Lefferts chairman of the ticket committee, and between them, by only the very slightest doctoring of the books, they turned forty dollars to the best of all possible uses.

At the beginning of Senior year, Elmer announced that he desired to be president again. To elect any one as class-president twice was taboo. The ardent Eddie Fislinger, now president of the Y. M. C. A. and ready to bring his rare talents to the Baptist ministry, asserted after an enjoyable private prayer-meeting in his room that he was going to face Elmer and forbid him to run.

“Gwan! You don’t dare!” observed a Judas who three minutes before had been wrestling with God under Eddie’s coaching.

“I don’t, eh? Watch me! Why, everybody hates him, the darn’ hog!” squeaked Eddie.

By scurrying behind trees he managed to come face to face with Elmer on the campus. He halted, and spoke of football, quantitative chemistry, and the Arkansas spinster who taught German.

Elmer grunted.

Desperately, his voice shrill with desire to change the world, Eddie stammered:

“Say—say, Hell-cat, you hadn’t ought to run for president again. Nobody’s ever president twice!”

“Somebody’s going to be.”

“Ah, gee, Elmer, don’t run for it. Ah, come on. Course all the fellows are crazy about you but— Nobody’s ever been president twice. They’ll vote against you.”

“Let me catch ’em at it!”

“How can you stop it? Honest, Elm—Hell-cat—I’m just speaking for your own good. The voting’s secret. You can’t tell—”

“Huh! The nominations ain’t secret! Now you go roll your hoop, Fissy, and let all the yellow coyotes know that anybody that nominates anybody except Uncle Hell-cat will catch it right where the chicken caught the ax. See? And if they tell me they didn’t know about this, you’ll get merry Hail Columbia for not telling ’em. Get me? If there’s anything but an unanimous vote, you won’t do any praying the rest of this year!”

Eddie remembered how Elmer and Jim had shown a Freshman his place in society by removing all his clothes and leaving him five miles in the country.

Elmer was elected president of the senior class—unanimously.

He did not know that he was unpopular. He reasoned that men who seemed chilly to him were envious and afraid, and that gave him a feeling of greatness.

Thus it happened that he had no friend save Jim Lefferts.

Only Jim had enough will to bully him into obedient admiration. Elmer swallowed ideas whole; he was a maelstrom of prejudices; but Jim accurately examined every notion that came to him. Jim was selfish enough, but it was with the selfishness of a man who thinks

and who is coldly unafraid of any destination to which his thoughts may lead him. The little man treated Elmer like a large damp dog, and Elmer licked his shoes and followed.

He also knew that Jim, as quarter, was far more the soul of the team than himself as tackle and captain.

A huge young man, Elmer Gantry; six foot one, thick, broad, big handed; a large face, handsome as a Great Dane is handsome, and a swirl of black hair, worn rather long. His eyes were friendly, his smile was friendly—oh, he was always friendly enough; he was merely astonished when he found that you did not understand his importance and did not want to hand over anything he might desire. He was a barytone solo turned into portly flesh; he was a gladiator laughing at the comic distortion of his wounded opponent.

He could not understand men who shrank from blood, who liked poetry or roses, who did not casually endeavor to seduce every possibly seducible girl. In sonorous arguments with Jim he asserted that “these fellows that study all the time are just letting on like they’re so doggone high and mighty, to show off to these doggone profs that haven’t got anything but lemonade in their veins.”

IV

Chief adornment of their room was the escritoire of the first Gritzmacher, which held their library. Elmer owned two volumes of Conan Doyle, one of E. P. Roe, and a priceless copy of “Only a Boy.” Jim had invested in an encyclopedia which explained any known subject in ten lines, in a “Pickwick Papers,” and from some unknown source he had obtained a complete Swinburne, into which he was never known to have looked.

But his pride was in the possession of Ingersoll’s “Some Mistakes of Moses,” and Paine’s “The Age of Reason.” For Jim Lefferts was the college freethinker, the only man in Terwillinger who doubted that Lot’s wife had been changed into salt for once looking back at the town where, among the young married set, she had had so good a time; who doubted that Methuselah lived to nine hundred and sixtynine.

They whispered of Jim all through the pious dens of Terwillinger Elmer himself was frightened, for after giving minutes and minutes to theological profundities Elmer had concluded that “there must be something to all this religious guff if all these wise old birds believe it, and some time a fellow had ought to settle down and cut out the hellraising.” Probably Jim would have been kicked out of college by the ministerial professors if he had not had so reverent a way of asking questions when they wrestled with his infidelity that they let go of him in nervous confusion.

Even the President, the Rev. Dr. Willoughby Quarles, formerly pastor of the Rock of Ages Baptist Church of Moline, Ill., than whom no man had written more about the necessity of baptism by immersion, in fact in every way a thoroughly than-whom figure— even when Dr. Quarles tackled Jim and demanded, “Are you getting the best out of our instruction, young man? Do you believe with us not only in the plenary inspiration of the Bible but also in its verbal inspiration, and that it is the only divine rule of faith and practise?” then Jim looked docile and said mildly:

“Oh, yes, Doctor. There’s just one or two little things that have been worrying me, Doctor. I’ve taken them to the Lord in prayer, but he doesn’t seem to help me much. I’m sure you can. Now why did Joshua need to have the sun stand still? Of course it happened—it says so right in Scripture. But why did he need to, when the Lord always helped those Jews, anyway, and when Joshua could knock down big walls just by having his people yell and blow trumpets? And if devils cause a lot of the diseases, and they had to cast ’em out, why is it that good Baptist doctors today don’t go on diagnosing devil-possession instead of T. B. and things like that? Do people have devils?”

“Young man, I will give you an infallible rule. Never question the ways of the Lord!”

“But why don’t the doctors talk about having devils now?”

“I have no time for vain arguments that lead nowhere! If you would think a little less of your wonderful powers of reasoning, if you’d go humbly to God in prayer and give him a chance, you’d understand the true spiritual significances of all these things.”

“But how about where Cain got his wife—”

Most respectfully Jim said it, but Dr. Quarles (he had a chinwhisker and a boiled shirt) turned from him and snapped, “I have no further time to give you, young man! I’ve told you what to do. Good morning!”

That evening Mrs. Quarles breathed, “Oh, Willoughby, did you ’tend to that awful senior—that Lefferts—that’s trying to spread doubt? Did you fire him?”

“No,” blossomed President Quarles. “Certainly not. There was no need. I showed him how to look for spiritual guidance and— Did that freshman come and mow the lawn? The idea of him wanting fifteen cents an hour!”

Jim was hair-hung and breeze-shaken over the abyss of hell, and apparently enjoying it very much indeed, while his wickedness fascinated Elmer Gantry and terrified him.

VThat November day of 1902, November of their Senior year, was greasy of sky, and slush blotted the wooden sidewalks of Gritzmacher Springs. There was nothing to do in town, and their room was dizzying with the stench of the stove, first lighted now since spring.

Jim was studying German, tilted back in an elegant position of ease, with his legs cocked up on the desk tablet of the escritoire. Elmer lay across the bed, ascertaining whether the blood would run to his head if he lowered it over the side. It did, always.

“Oh, God, let’s get out and do something!” he groaned.

“Nothing to do, Useless,” said Jim.

“Let’s go over to Cato and see the girls and get drunk.”

As Kansas was dry, by state prohibition, the nearest haven was at Cato, Missouri, seventeen miles away.

Jim scratched his head with a corner of his book, and approved:

“Well, that’s a worthy idea. Got any money?”

“On the twenty-eighth? Where the hell would I get any money before the first?”

“Hell-cat, you’ve got one of the deepest intellects I know. You’ll be a knock-out at the law Aside from neither of us having any money, and me with a Dutch quiz tomorrow, it’s a great project.”

“Oh, well—” sighed the ponderous Elmer, feebly as a sick kitten, and lay revolving the tremendous inquiry.

It was Jim who saved them from the lard-like weariness into which they were slipping. He had gone back to his book, but he placed it, precisely and evenly, on the desk, and rose.

“I would like to see Nellie,” he sighed. “Oh, man, I could give her a good time! Little devil! Damn these co-eds here. The few that’ll let you love ’em up, they hang around trying to catch you on the campus and make you propose to ’em.”

“Oh, gee! And I got to see Juanita,” groaned Elmer. “Hey, cut out talking about ’em, will you! I’ve got a palpitating heart right now, just thinking about Juanny!”

“Hell-cat! I’ve got it. Go and borrow ten off this new instructor in chemistry and physics. I’ve got a dollar sixty-four left, and that’ll make it.”

“But I don’t know him.”

“Sure, you poor fish. That’s why I suggested him! Do the checkfailed-to-come. I’ll get another hour of this Dutch while you’re stealing the ten from him—”

“Now,” lugubriously, “you oughtn’t to talk like that!”

“If you’re as good a thief as I think you are, we’ll catch the fivesixteen to Cato.”

They were on the five-sixteen for Cato.

The train consisted of a day-coach, a combined smoker and baggage car, and a rusty old engine and tender. The train swayed so on the rough tracks as it bumped through the drooping light that Elmer and Jim were thrown against each other and gripped the arm of their seat. The car staggered like a freighter in a gale. And tall raw farmers, perpetually shuffling forward for a drink at the water-cooler,

stumbled against them or seized Jim’s shoulder to steady themselves.

To every surface of the old smoking-car, to streaked windows and rusty ironwork and mud-smeared cocoanut matting, clung a sickening bitterness of cheap tobacco fumes, and whenever they touched the red plush of the seat, dust whisked up and the prints of their hands remained on the plush. The car was jammed. Passengers came to sit on the arm of their seat to shout at friends across the aisle.

But Elmer and Jim were unconscious of filth and smell and crowding. They sat silent, nervously intent, panting a little, their lips open, their eyes veiled, as they thought of Juanita and Nellie.

The two girls, Juanita Klauzel and Nellie Benton, were by no means professional daughters of joy. Juanita was cashier of the Cato Lunch—Quick Eats; Nellie was assistant to a dressmaker. They were good girls but excitable, and they found a little extra money useful for red slippers and nut-center chocolates.

“Juanita—what a lil darling—she understands a fellow’s troubles,” said Elmer, as they balanced down the slushy steps at the grimy stone station of Cato.

When Elmer, as a Freshman just arrived from the pool-halls and frame high school of Paris, Kansas, had begun to learn the decorum of amour, he had been a boisterous lout who looked shamefaced in the presence of gay ladies, who blundered against tables, who shouted and desired to let the world know how valiantly vicious he was being. He was still rather noisy and proud of wickedness when he was in a state of liquor, but in three and a quarter years of college he had learned how to approach girls. He was confident, he was easy, he was almost quiet; he could look them in the eye with fondness and amusement.

Juanita and Nellie lived with Nellie’s widow aunt—she was a moral lady, but she knew how to keep out of the way—in three rooms over a corner grocery. They had just returned from work when Elmer and Jim stamped up the rickety outside wooden steps. Juanita was lounging on a divan which even a noble Oriental red and yellow cover (displaying a bearded Wazir, three dancing ladies in chiffon

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.