logo资料库

Computer Graphics Programming in OpenGL with C++.pdf

第1页 / 共455页
第2页 / 共455页
第3页 / 共455页
第4页 / 共455页
第5页 / 共455页
第6页 / 共455页
第7页 / 共455页
第8页 / 共455页
资料共455页,剩余部分请下载后查看
Title Page
Copyright
Contents
Preface
Intended Audience
How to Use This Book
Acknowledgments
About the Authors
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 Graphics 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 Dot Product
3.5.2 Uses for Cross Product
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 – Special Effects
Appendix A Installation and Setup for PC (Windows)
Appendix B Installation and Setup for Macintosh
Appendix C Using the Nsight Graphics Debugger
Index
COMPUTER GRAPHICS PROGRAMMING IN OPENGL WITH C++
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. This license does not permit uploading of the Work onto the Internet 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” vary 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 publisher at info@merclearning.com.
COMPUTER GRAPHICS PROGRAMMING IN OPENGL WITH C++ V. Scott Gordon, Ph.D. California State University, Sacramento John Clevenger, Ph.D. California State University, Sacramento MERCURY LEARNING AND INFORMATION Dulles, Virginia Boston, Massachusetts New Delhi
Copyright ©2019 by MERCURY LEARNING AND INFORMATION LLC. All rights reserved. This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means, media, electronic display or mechanical display, including, but not limited to, photocopy, recording, Internet postings, or scanning, without prior permission in writing from the publisher. Publisher: David Pallai MERCURY LEARNING AND INFORMATION 22841 Quicksilver Drive Dulles, VA 20166 info@merclearning.com www.merclearning.com (800) 232-0223 V. Scott Gordon & John Clevenger. Computer Graphics Programming in OpenGL with C++ ISBN: 978-1-683922-21-6 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: 2018949985 181920321    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.authorcloudware.com and other e-vendors. All companion files are available by writing to the publisher at info@merclearning.com. The sole obligation of MERCURY LEARNING AND INFORMATION to the purchaser is to replace the book and/or disc, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.
Contents Preface Intended Audience How to Use This Book Acknowledgments About the Authors 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 Graphics 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 Dot Product 3.5.2 Uses for Cross Product 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
分享到:
收藏