logo资料库

OpenGL SuperBible 7 pdf.pdf

第1页 / 共1544页
第2页 / 共1544页
第3页 / 共1544页
第4页 / 共1544页
第5页 / 共1544页
第6页 / 共1544页
第7页 / 共1544页
第8页 / 共1544页
资料共1544页,剩余部分请下载后查看
About This eBook
Title Page
Copyright Page
Dedication Page
Contents
Figures
Tables
Listings
Foreword
Preface
The Architecture of the Book
What’s New in This Edition
How to Build the Examples
Errata
Note from the Publisher
Acknowledgments
About the Author
Part I: Foundations
Chapter 1. Introduction
OpenGL and the Graphics Pipeline
The Origins and Evolution of OpenGL
Core Profile OpenGL
Primitives, Pipelines, and Pixels
Summary
Chapter 2. Our First OpenGL Program
Creating a Simple Application
Using Shaders
Drawing Our First Triangle
Summary
Chapter 3. Following the Pipeline
Passing Data to the Vertex Shader
Vertex Attributes
Passing Data from Stage to Stage
Interface Blocks
Tessellation
Tessellation Control Shaders
The Tessellation Engine
Tessellation Evaluation Shaders
Geometry Shaders
Primitive Assembly, Clipping, and Rasterization
Clipping
Viewport Transformation
Culling
Rasterization
Fragment Shaders
Framebuffer Operations
Pixel Operations
Compute Shaders
Using Extensions in OpenGL
Enhancing OpenGL with Extensions
Summary
Chapter 4. Math for 3D Graphics
Is This the Dreaded Math Chapter?
A Crash Course in 3D Graphics Math
Vectors, or Which Way Is Which?
Common Vector Operators
Matrices
Matrix Construction and Operators
Understanding Transformations
Coordinate Spaces in OpenGL
Coordinate Transformations
Concatenating Transformations
Quaternions
The Model–View Transform
Projection Transformations
Interpolation, Lines, Curves, and Splines
Curves
Splines
Summary
Chapter 5. Data
Buffers
Creating Buffers and Allocating Memory
Filling and Copying Data in Buffers
Feeding Vertex Shaders from Buffers
Uniforms
Default Block Uniforms
Uniform Blocks
Using Uniforms to Transform Geometry
Shader Storage Blocks
Synchronizing Access to Memory
Atomic Counters
Synchronizing Access to Atomic Counters
Textures
Creating and Initialzing Textures
Texture Targets and Types
Reading from Textures in Shaders
Loading Textures from Files
Controlling How Texture Data Is Read
Array Textures
Writing to Textures in Shaders
Synchronizing Access to Images
Texture Compression
Texture Views
Summary
Chapter 6. Shaders and Programs
Language Overview
Data Types
Built-In Functions
Compiling, Linking, and Examining Programs
Getting Information from the Compiler
Getting Information from the Linker
Separate Programs
Shader Subroutines
Program Binaries
Summary
Part II: In Depth
Chapter 7. Vertex Processing and Drawing Commands
Vertex Processing
Vertex Shader Inputs
Vertex Shader Outputs
Drawing Commands
Indexed Drawing Commands
Instancing
Indirect Draws
Storing Transformed Vertices
Using Transform Feedback
Starting, Pausing, and Stopping Transform Feedback
Ending the Pipeline with Transform Feedback
Transform Feedback Example: Physical Simulation
Clipping
User-Defined Clipping
Summary
Chapter 8. Primitive Processing
Tessellation
Tessellation Primitive Modes
Tessellation Subdivision Modes
Passing Data between Tessellation Shaders
Communication between Shader Invocations
Tessellation Example: Terrain Rendering
Tessellation Example: Cubic Bézier Patches
Geometry Shaders
The Pass-Through Geometry Shader
Using Geometry Shaders in an Application
Discarding Geometry in the Geometry Shader
Modifying Geometry in the Geometry Shader
Generating Geometry in the Geometry Shader
Changing the Primitive Type in the Geometry Shader
Multiple Streams of Storage
New Primitive Types Introduced by the Geometry Shader
Multiple Viewport Transformations
Summary
Chapter 9. Fragment Processing and the Framebuffer
Fragment Shaders
Interpolation and Storage Qualifiers
Per-Fragment Tests
Scissor Testing
Stencil Testing
Depth Testing
Early Testing
Color Output
Blending
Logical Operations
Color Masking
Off-Screen Rendering
Multiple Framebuffer Attachments
Layered Rendering
Framebuffer Completeness
Rendering in Stereo
Antialiasing
Antialiasing by Filtering
Multi-Sample Antialiasing
Multi-Sample Textures
Sample Rate Shading
Centroid Sampling
Advanced Framebuffer Formats
Rendering with No Attachments
Floating-Point Framebuffers
Integer Framebuffers
The sRGB Color Space
Point Sprites
Texturing Points
Rendering a Star Field
Point Parameters
Shaped Points
Rotating Points
Getting at Your Image
Reading from a Framebuffer
Copying Data between Framebuffers
Reading Back Texture Data
Summary
Chapter 10. Compute Shaders
Using Compute Shaders
Executing Compute Shaders
Compute Shader Communication
Examples
Compute Shader Parallel Prefix Sum
Compute Shader Flocking
Summary
Chapter 11. Advanced Data Management
Eliminating Binding
Sparsely Populated Textures
Texture Compression
The RGTC Compression Scheme
Generating Compressed Data
Packed Data Formats
High-Quality Texture Filtering
Summary
Chapter 12. Controlling and Monitoring the Pipeline
Queries
Occlusion Queries
Timer Queries
Transform Feedback Queries
Pipeline State Queries
Synchronization in OpenGL
Draining the Pipeline
Synchronization and Fences
Summary
Part III: In Practice
Chapter 13. Rendering Techniques
Lighting Models
The Phong Lighting Model
Blinn-Phong Lighting
Rim Lighting
Normal Mapping
Environment Mapping
Material Properties
Casting Shadows
Atmospheric Effects
Non-Photo-Realistic Rendering
Cell Shading: Texels as Light
Alternative Rendering Methods
Deferred Shading
Screen-Space Techniques
Rendering without Triangles
Two-Dimensional Graphics
Distance Field Textures
Bitmap Fonts
Summary
Chapter 14. High-Performance OpenGL
Optimizing CPU Performance
Multi-Threading in OpenGL
Packet Buffers
Low-Overhead OpenGL
Indirect Rendering
GPU Work Generation
Zero Copy
Performance Analysis Tools
Windows Performance Toolkit and GPUView
GPU PerfStudio
Tuning Your Application for Speed
Summary
Chapter 15. Debugging and Stability
Debugging Your Applications
Debug Contexts
Security and Robustness
Graphics Reset
Range-Checked Reads
Summary
Appendix A. The SuperBible Tools
The ktxtool Utility
The dds2ktx Utility
The sb6mtool Utility
Appendix B. The SBM File Format
File Header
Chunk Headers
Defined Chunks
Example
Appendix C. OpenGL Features and Versions
List of OpenGL Functions
Functions Introduced by OpenGL Extensions
Glossary
Index
Code Snippets
About This eBook ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturer’s Web site. Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a “Click here to view code image” link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
OpenGL® SuperBible Seventh Edition Comprehensive Tutorial and Reference Graham Sellers Richard S. Wright, Jr. Nicholas Haemel New York • Boston • Indianapolis • San Francisco Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. OpenGL® is a registered trademark of Silicon Graphics Inc. and is used by permission of Khronos. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at corpsales@pearsoned.com or (800) 382-3419. For government sales inquiries, please contact governmentsales@pearsoned.com. For questions about sales outside the United States, please contact international@pearsoned.com. Visit us on the Web: informit.com/aw Library of Congress Cataloging-in-Publication Data Wright, Richard S., Jr., 1965- author. OpenGL superBible : comprehensive tutorial and reference.— Seventh edition / Graham Sellers, Richard S. Wright, Jr., Nicholas Haemel. pages cm Includes bibliographical references and index. ISBN 978-0-672-33747-5 (pbk. : alk. paper)—ISBN 0-672-33747-9 (pbk. : alk. paper) 1. Computer graphics. 2. OpenGL. I. Sellers, Graham, author. II. Haemel, Nicholas, author. III. Title. T385.W728 2016 006.6’8—dc23 2015014278 Copyright © 2016 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any
prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, 200 Old Tappan Road, Old Tappan, New Jersey 07675, or you may fax your request to (201) 236-3290. ISBN-13: 978-0-672-33747-5 ISBN-10: 0-672-33747-9 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing, July 2015 Editor-in-Chief Mark L. Taub Executive Editor Laura Lewin Managing Editor John Fuller Full-Service Production Manager Julie B. Nahil Copy Editor Jill Hobbs Indexer Larry D. Sweazy Proofreader Anna Popick Technical Reviewer Matías Goldberg Editorial Assistant Olivia Basegio Compositor diacriTech
For you, the reader. —Graham Sellers
分享到:
收藏