在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例Clojure → Addison.Wesley.OpenGL.Programming.Guide.8th.Edition.PDF

Addison.Wesley.OpenGL.Programming.Guide.8th.Edition.PDF

Clojure

下载此实例
  • 开发语言:Others
  • 实例大小:11.58M
  • 下载次数:7
  • 浏览次数:44
  • 发布时间:2022-05-11
  • 实例类别:Clojure
  • 发 布 人:yses
  • 文件格式:.pdf
  • 所需积分:2
 相关标签: Programming OpenGL GUIDE OPENG edit

实例介绍

【实例简介】Addison.Wesley.OpenGL.Programming.Guide.8th.Edition.Mar.2013.ISBN.0321773039

【实例截图】

【核心代码】

Contents
Figures.....................................................................................................xxiii
Tables. ......................................................................................................xxix
Examples............................................................................................... xxxiii
About This Guide . ..................................................................................... xli
What This Guide Contains ........................................................................xli
What’s New in This Edition . ................................................................... xliii
What You Should Know Before Reading This Guide. ............................. xliii
How to Obtain the Sample Code ............................................................ xliv
Errata. ........................................................................................................ xlv
Style Conventions. .................................................................................... xlv
1. Introduction to OpenGL. ..............................................................................1
What Is OpenGL? .........................................................................................2
Your First Look at an OpenGL Program........................................................3
OpenGL Syntax. ...........................................................................................8
OpenGL’s Rendering Pipeline. ................................................................... 10
Preparing to Send Data to OpenGL. ...................................................... 11
Sending Data to OpenGL....................................................................... 11
Vertex Shading . ..................................................................................... 12
Tessellation Shading .............................................................................. 12
Geometry Shading. ................................................................................ 12
Primitive Assembly. ............................................................................... 12
Clipping ................................................................................................. 13
Rasterization .......................................................................................... 13
Fragment Shading . ................................................................................ 13
ix
Per-Fragment Operations ....................................................................... 13
Our First Program: A Detailed Discussion. ................................................ 14
Entering main(). .................................................................................... 14
OpenGL Initialization . .......................................................................... 16
Our First OpenGL Rendering................................................................. 28
2. Shader Fundamentals . .............................................................................. 33
Shaders and OpenGL. ................................................................................ 34
OpenGL’s Programmable Pipeline. ............................................................ 35
An Overview of the OpenGL Shading Language....................................... 37
Creating Shaders with GLSL . ..................................................................... 37
Storage Qualifiers ....................................................................................... 45
Statements .................................................................................................. 49
Computational Invariance ......................................................................... 54
Shader Preprocessor. .................................................................................. 56
Compiler Control....................................................................................... 58
Global Shader-Compilation Option. ......................................................... 59
Interface Blocks .......................................................................................... 60
Uniform Blocks. ......................................................................................... 61
Specifying Uniform Blocks in Shaders ....................................................... 61
Accessing Uniform Blocks from Your Application..................................... 63
Buffer Blocks . ............................................................................................. 69
In/Out Blocks ............................................................................................. 70
Compiling Shaders. .................................................................................... 70
Our LoadShaders() Function . ............................................................ 76
Shader Subroutines .................................................................................... 76
GLSL Subroutine Setup............................................................................... 77
Selecting Shader Subroutines..................................................................... 78
Separate Shader Objects ............................................................................. 81
3. Drawing with OpenGL . .............................................................................. 85
OpenGL Graphics Primitives...................................................................... 86
Points ......................................................................................................... 87
Lines, Strips, and Loops. ............................................................................ 88
Triangles, Strips, and Fans.......................................................................... 89
Data in OpenGL Buffers............................................................................. 92
Creating and Allocating Buffers ............................................................ 92
Getting Data into and out of Buffers..................................................... 95
x Contents
Accessing the Content of Buffers............................................................. 100
Discarding Buffer Data . ........................................................................... 107
Vertex Specification . ............................................................................... 108
VertexAttribPointer in Depth . ................................................................ 108
Static Vertex-Attribute Specification........................................................ 112
OpenGL Drawing Commands................................................................. 115
Restarting Primitives............................................................................ 124
Instanced Rendering . .............................................................................. 128
Instanced Vertex Attributes................................................................. 129
Using the Instance Counter in Shaders............................................... 136
Instancing Redux . ............................................................................... 139
4. Color, Pixels, and Framebuffers. .............................................................141
Basic Color Theory................................................................................... 142
Buffers and Their Uses ............................................................................. 144
Clearing Buffers ....................................................................................... 146
Masking Buffers ....................................................................................... 147
Color and OpenGL . ................................................................................ 148
Color Representation and OpenGL. ........................................................ 149
Vertex Colors............................................................................................ 150
Rasterization ............................................................................................ 153
Multisampling.......................................................................................... 153
Sample Shading ................................................................................... 155
Testing and Operating on Fragments. ..................................................... 156
Scissor Test. .............................................................................................. 157
Multisample Fragment Operations ......................................................... 158
Stencil Test. .............................................................................................. 159
Stencil Examples ...................................................................................... 161
Depth Test . .............................................................................................. 163
Blending................................................................................................... 166
Blending Factors ...................................................................................... 167
Controlling Blending Factors................................................................... 167
The Blending Equation. ........................................................................... 170
Dithering.................................................................................................. 171
Logical Operations . ................................................................................. 171
Occlusion Query ...................................................................................... 173
Conditional Rendering. ........................................................................... 176
Per-Primitive Antialiasing........................................................................ 178
Contents xi
Antialiasing Lines. ................................................................................... 179
Antialiasing Polygons. ............................................................................. 180
Framebuffer Objects . ............................................................................... 180
Renderbuffers . ......................................................................................... 183
Creating Renderbuffer Storage . ............................................................... 185
Framebuffer Attachments . ...................................................................... 187
Framebuffer Completeness. ..................................................................... 190
Invalidating Framebuffers. ...................................................................... 192
Writing to Multiple Renderbuffers Simultaneously................................. 193
Selecting Color Buffers for Writing and Reading .................................... 195
Dual-Source Blending............................................................................... 198
Reading and Copying Pixel Data ............................................................ 200
Copying Pixel Rectangles ........................................................................ 203
5. Viewing Transformations, Clipping, and Feedback.................................205
Viewing . .................................................................................................. 206
Viewing Model . ....................................................................................... 207
Camera Model . ........................................................................................ 207
Orthographic Viewing Model . ................................................................ 212
User Transformations .............................................................................. 212
Matrix Multiply Refresher. ...................................................................... 214
Homogeneous Coordinates ..................................................................... 215
Linear Transformations and Matrices . .................................................... 219
Transforming Normals . ........................................................................... 231
OpenGL Matrices . ................................................................................... 232
OpenGL Transformations........................................................................ 236
Advanced: User Clipping. ................................................................... 238
Transform Feedback . ............................................................................... 239
Transform Feedback Objects................................................................ 239
Transform Feedback Buffers................................................................. 241
Configuring Transform Feedback Varyings......................................... 244
Starting and Stopping Transform Feedback ........................................ 250
Transform Feedback Example---Particle System .................................. 252
6. Textures.....................................................................................................259
Texture Mapping . .................................................................................... 261
Basic Texture Types . ................................................................................ 262
Creating and Initializing Textures........................................................... 263
xii Contents
Texture Formats ................................................................................... 270
Proxy Textures.......................................................................................... 276
Specifying Texture Data . ......................................................................... 277
Explicitly Setting Texture Data. ............................................................... 277
Using Pixel Unpack Buffers ..................................................................... 280
Copying Data from the Framebuffer ....................................................... 281
Loading Images from Files . ..................................................................... 282
Retrieving Texture Data........................................................................... 287
Texture Data Layout ................................................................................ 288
Sampler Objects. ...................................................................................... 292
Sampler Parameters ............................................................................. 294
Using Textures ......................................................................................... 295
Texture Coordinates................................................................................. 298
Arranging Texture Data ........................................................................... 302
Using Multiple Textures........................................................................... 303
Complex Texture Types............................................................................ 306
3D Textures. ............................................................................................. 307
Array Textures . ........................................................................................ 309
Cube-Map Textures. ................................................................................. 309
Shadow Samplers . ................................................................................... 317
Depth-Stencil Textures . ........................................................................... 318
Buffer Textures. ........................................................................................ 319
Texture Views. .......................................................................................... 321
Compressed Textures. .............................................................................. 326
Filtering . .................................................................................................. 329
Linear Filtering . ....................................................................................... 330
Using and Generating Mipmaps.............................................................. 333
Calculating the Mipmap Level. ............................................................... 338
Mipmap Level-of-Detail Control ............................................................. 339
Advanced Texture Lookup Functions. ..................................................... 340
Explicit Level of Detail . ........................................................................... 340
Explicit Gradient Specification ............................................................... 340
Texture Fetch with Offsets . ..................................................................... 341
Projective Texturing................................................................................. 342
Texture Queries in Shaders. ..................................................................... 343
Gathering Texels ...................................................................................... 345
Combining Special Functions. ................................................................ 345
Point Sprites . ........................................................................................... 346
Contents xiii
Textured Point Sprites . ............................................................................ 347
Controlling the Appearance of Points . ................................................... 350
Rendering to Texture Maps...................................................................... 351
Discarding Rendered Data. .................................................................. 354
Chapter Summary.................................................................................... 356
Texture Redux. ..................................................................................... 356
Texture Best Practices. ......................................................................... 357
7. Light and Shadow ....................................................................................359
Lighting Introduction.............................................................................. 360
Classic Lighting Model ............................................................................ 361
Fragment Shaders for Different Light Styles............................................ 362
Moving Calculations to the Vertex Shader . ............................................ 373
Multiple Lights and Materials. ................................................................ 376
Lighting Coordinate Systems................................................................... 383
Limitations of the Classic Lighting Model. ............................................. 383
Advanced Lighting Models ...................................................................... 384
Hemisphere Lighting ............................................................................... 384
Image-Based Lighting. ............................................................................. 389
Lighting with Spherical Harmonics ........................................................ 395
Shadow Mapping. .................................................................................... 400
Creating a Shadow Map....................................................................... 401
8. Procedural Texturing . ..............................................................................411
Procedural Texturing . .............................................................................. 412
Regular Patterns ....................................................................................... 414
Toy Ball .................................................................................................... 422
Lattice. ..................................................................................................... 431
Procedural Shading Summary. ................................................................ 432
Bump Mapping . ...................................................................................... 433
Application Setup. ................................................................................... 436
Vertex Shader . ......................................................................................... 438
Fragment Shader ...................................................................................... 439
Normal Maps............................................................................................ 441
Antialiasing Procedural Textures. ............................................................ 442
Sources of Aliasing. .............................................................................. 442
Avoiding Aliasing. ............................................................................... 444
xiv Contents
Increasing Resolution. ............................................................................. 445
Antialiasing High Frequencies . ............................................................... 447
Frequency Clamping................................................................................ 457
Procedural Antialiasing Summary. .......................................................... 459
Noise. ....................................................................................................... 460
Definition of Noise. ................................................................................. 461
Noise Textures . ........................................................................................ 468
Trade-offs.................................................................................................. 471
A Simple Noise Shader . ........................................................................... 472
Turbulence. .............................................................................................. 475
Marble. ..................................................................................................... 477
Granite. .................................................................................................... 478
Wood........................................................................................................ 478
Noise Summary. ....................................................................................... 483
Further Information. ............................................................................... 483
9. Tessellation Shaders. ...............................................................................485
Tessellation Shaders. ................................................................................ 486
Tessellation Patches. ................................................................................ 487
Tessellation Control Shaders . .................................................................. 488
Generating Output-Patch Vertices . ......................................................... 489
Tessellation Control Shader Variables. .................................................... 490
Controlling Tessellation .......................................................................... 491
Tessellation Evaluation Shaders . ............................................................. 496
Specifying the Primitive Generation Domain . ....................................... 497
Specifying the Face Winding for Generated Primitives .......................... 497
Specifying the Spacing of Tessellation Coordinates................................ 498
Additional Tessellation Evaluation Shader layout Options .................. 498
Specifying a Vertex’s Position . ................................................................ 498
Tessellation Evaluation Shader Variables................................................. 499
A Tessellation Example: The Teapot . ...................................................... 500
Processing Patch Input Vertices............................................................... 501
Evaluating Tessellation Coordinates for the Teapot................................ 501
Additional Tessellation Techniques . ....................................................... 504
View-Dependent Tessellation. ............................................................. 504
Shared Tessellated Edges and Cracking ............................................... 506
Displacement Mapping ....................................................................... 507
Contents xv
10. Geometry Shaders....................................................................................509
Creating a Geometry Shader . .................................................................. 510
Geometry Shader Inputs and Outputs .................................................... 514
Geometry Shader Inputs.......................................................................... 514
Special Geometry Shader Primitives........................................................ 517
Geometry Shader Outputs . ..................................................................... 523
Producing Primitives . .............................................................................. 525
Culling Geometry . .................................................................................. 525
Geometry Amplification.......................................................................... 527
Advanced Transform Feedback ................................................................ 532
Multiple Output Streams ......................................................................... 533
Primitive Queries . ................................................................................... 537
Using Transform Feedback Results. ......................................................... 539
Geometry Shader Instancing. .................................................................. 549
Multiple Viewports and Layered Rendering . .......................................... 550
Viewport Index. ....................................................................................... 550
Layered Rendering. .................................................................................. 556
Chapter Summary.................................................................................... 559
Geometry Shader Redux ...................................................................... 560
Geometry Shader Best Practices .......................................................... 561
11. Memory .....................................................................................................563
Using Textures for Generic Data Storage . ............................................... 564
Binding Textures to Image Units ............................................................. 569
Reading from and Writing to Images . .................................................... 572
Shader Storage Buffer Objects.................................................................. 576
Writing Structured Data....................................................................... 577
Atomic Operations and Synchronization ............................................... 578
Atomic Operations on Images . ............................................................... 578
Atomic Operations on Buffers. ................................................................ 587
Sync Objects............................................................................................. 589
Image Qualifiers and Barriers................................................................... 593
High Performance Atomic Counters ....................................................... 605
Example. .................................................................................................. 609
Order-Independent Transparency. ...................................................... 609
xvi Contents
12. Compute Shaders. ....................................................................................623
Overview. ................................................................................................. 624
Workgroups and Dispatch ....................................................................... 625
Knowing Where You Are . ................................................................... 630
Communication and Synchronization.................................................... 632
Communication ...................................................................................... 633
Synchronization ...................................................................................... 634
Examples. ................................................................................................. 636
Physical Simulation ................................................................................. 636
Image Processing...................................................................................... 642
Chapter Summary.................................................................................... 647
Compute Shader Redux....................................................................... 647
Compute Shader Best Practices ........................................................... 648
A. Basics of GLUT: The OpenGL Utility Toolkit. ..........................................651
Initializing and Creating a Window . ...................................................... 652
Accessing Functions . ............................................................................... 654
Handling Window and Input Events . ..................................................... 655
Managing a Background Process. ............................................................ 658
Running the Program .............................................................................. 658
B. OpenGL ES and WebGL . .........................................................................659
OpenGL ES ............................................................................................... 660
WebGL ..................................................................................................... 662
Setting up WebGL within an HTML5 page......................................... 662
Initializing Shaders in WebGL ............................................................ 664
Initializing Vertex Data in WebGL. ..................................................... 667
Using Texture Maps in WebGL............................................................ 668
C. Built-in GLSL Variables and Functions ...................................................673
Built-in Variables . .................................................................................... 674
Built-in Variable Declarations . ................................................................ 674
Built-in Variable Descriptions . ................................................................ 676
Built-in Constants.................................................................................... 684
Built-in Functions.................................................................................... 686
Angle and Trigonometry Functions .................................................... 688
Exponential Functions ........................................................................ 690
Common Functions............................................................................. 692
Floating-Point Pack and Unpack Functions........................................ 698
Contents xvii
Geometric Functions . ......................................................................... 700
Matrix Functions. ................................................................................ 702
Vector Relational Functions ................................................................ 703
Integer Functions . ............................................................................... 705
Texture Functions. ............................................................................... 708
Atomic-Counter Functions.................................................................. 722
Atomic Memory Functions ................................................................. 723
Image Functions . ................................................................................ 725
Fragment Processing Functions........................................................... 729
Noise Functions ................................................................................... 731
Geometry Shader Functions ................................................................ 732
Shader Invocation Control Functions . ............................................... 734
Shader Memory Control Functions..................................................... 734
D. State Variables..........................................................................................737
The Query Commands............................................................................. 738
OpenGL State Variables............................................................................ 745
Current Values and Associated Data.................................................... 746
Vertex Array Object State. ................................................................... 747
Vertex Array Data. ............................................................................... 749
Buffer Object State. .............................................................................. 750
Transformation State............................................................................ 751
Coloring State. ..................................................................................... 752
Rasterization State . .............................................................................. 753
Multisampling . .................................................................................... 755
Textures................................................................................................ 756
Textures................................................................................................ 759
Textures................................................................................................ 762
Textures................................................................................................ 764
Texture Environment. ......................................................................... 766
Pixel Operations................................................................................... 767
Framebuffer Controls. ......................................................................... 770
Framebuffer State . ............................................................................... 771
Framebuffer State . ............................................................................... 772
Frambuffer State................................................................................... 773
Renderbuffer State. .............................................................................. 775
Renderbuffer State. .............................................................................. 776
Pixel State . ........................................................................................... 778
xviii Contents
Shader Object State.............................................................................. 781
Shader Program Pipeline Object State . ............................................... 782
Shader Program Object State . ............................................................. 783
Program Interface State ....................................................................... 793
Program Object Resource State............................................................ 794
Vertex and Geometry Shader State ..................................................... 797
Query Object State .............................................................................. 797
Image State .......................................................................................... 798
Transform Feedback State . .................................................................. 799
Atomic Counter State. ......................................................................... 800
Shader Storage Buffer State.................................................................. 801
Sync Object State . ............................................................................... 802
Hints..................................................................................................... 803
Compute Dispatch State...................................................................... 803
Implementation-Dependent Values .................................................... 804
Tessellation Shader Implementation-Dependent Limits..................... 810
Geometry Shader Implementation-Dependent Limits....................... 813
Fragment Shader Implementation-Dependent Limits. ....................... 815
Implementation-Dependent Compute Shader Limits. ....................... 816
Implementation-Dependent Shader Limits ........................................ 818
Implementation-Dependent Debug Output State. ............................. 823
Implementation-Dependent Values .................................................... 824
Internal Format-Dependent Values..................................................... 826
Implementation-Dependent Transform Feedback Limits . ................. 826
Framebuffer-Dependent Values........................................................... 827
Miscellaneous. ..................................................................................... 827
E. Homogeneous Coordinates and Transformation Matrices.....................829
Homogeneous Coordinates...................................................................... 830
Transforming Vertices . ............................................................................ 830
Transforming Normals . ........................................................................... 831
Transformation Matrices . ........................................................................ 831
Translation. .......................................................................................... 832
Scaling ................................................................................................. 832
Rotation ............................................................................................... 832
Perspective Projection . ........................................................................ 834
Orthographic Projection...................................................................... 834
Contents xix
F. OpenGL and Window Systems ................................................................835
Accessing New OpenGL Functions.......................................................... 836
GLEW: The OpenGL Extension Wrangler . ......................................... 837
GLX: OpenGL Extension for the X Window System. ............................. 838
Initialization ............................................................................................ 839
Controlling Rendering . ........................................................................... 840
GLX Prototypes ....................................................................................... 842
WGL: OpenGL Extensions for Microsoft Windows . .............................. 845
Initialization . ...................................................................................... 846
Controlling Rendering ........................................................................ 846
WGL Prototypes................................................................................... 848
OpenGLinMacOSX:TheCoreOpenGL(CGL)APIandtheNSOpenGL
Classes . ............................................................................................ 850
Mac OS X’s Core OpenGL Library ........................................................... 851
Initialization ............................................................................................ 851
Controlling Rendering . ........................................................................... 852
CGL Prototypes. ....................................................................................... 852
The NSOpenGL Classes............................................................................ 854
Initialization . ...................................................................................... 854
G. Floating-Point Formats for Textures, Framebuffers, and
Renderbuffers. ..........................................................................................857
Reduced-Precision Floating-Point Values. ............................................... 858
16-bit Floating-Point Values. ................................................................... 858
10- and 11-bit Unsigned Floating-Point Values. ..................................... 860
H. Debugging and Profiling OpenGL ...........................................................865
Creating a Debug Context....................................................................... 866
Debug Output.......................................................................................... 868
Debug Messages ....................................................................................... 869
Filtering Messages . .................................................................................. 872
Application-Generated Messages............................................................. 874
Debug Groups.......................................................................................... 875
Naming Objects ................................................................................... 877
Profiling. .................................................................................................. 879
Profiling Tools . .................................................................................... 879
In-Application Profiling....................................................................... 881
xx Contents
I. Buffer Object Layouts ..............................................................................885
Using Standard Layout Qualifiers............................................................ 886
The std140 Layout Rules........................................................................ 886
The std430 Layout Rules........................................................................ 887
Glossary. ..................................................................................................889
Index. ........................................................................................................919

实例下载地址

Addison.Wesley.OpenGL.Programming.Guide.8th.Edition.PDF

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警