The OpenGL ES 2.0 programming guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Aaftab Munshi; Dan Ginsburg; Dave Shreiner
Publisher: Addison-Wesley
Year: 2009

Language: English
Pages: 445
City: Upper Saddle River, NJ

Contents......Page 3
List of Figures......Page 11
List of Examples......Page 13
List of Tables......Page 16
Foreword......Page 18
Intended Audience......Page 20
Organization of the Book......Page 21
Errata......Page 25
Acknowledgments......Page 26
About the Authors......Page 28
What Is OpenGL ES?......Page 29
OpenGL ES 2.0......Page 31
Vertex Shader......Page 32
Primitive Assembly......Page 34
Fragment Shader......Page 35
Per-Fragment Operations......Page 37
OpenGL ES 2.0 and OpenGL ES 1.x Backward Compatibility......Page 39
EGL......Page 40
Libraries and Include Files......Page 41
OpenGL ES Command Syntax......Page 42
Error Handling......Page 43
Flush and Finish......Page 44
Basic State Management......Page 45
Further Reading......Page 46
2. Hello Triangle: An OpenGL ES 2.0 Example......Page 47
Where to Download the Examples......Page 48
Hello Triangle Example......Page 49
Building and Running the Examples......Page 53
Using the OpenGL ES 2.0 Framework......Page 54
Creating a Simple Vertex and Fragment Shader......Page 55
Compiling and Loading the Shaders......Page 57
Creating a Program Object and Linking the Shaders......Page 58
Setting the Viewport and Clearing the Color Buffer......Page 60
Displaying the Back Buffer......Page 61
3. An Introduction to EGL......Page 63
Communicating with the Windowing System......Page 64
Initializing EGL......Page 65
Determining the Available Surface Configurations......Page 66
Letting EGL Choose the Config......Page 67
Creating an On-Screen Rendering Area: The EGL Window......Page 71
Creating an Off-Screen Rendering Area: EGL Pbuffers......Page 74
Creating a Rendering Context......Page 78
Putting All Our EGL Knowledge Together......Page 80
Synchronizing Rendering......Page 82
Shaders and Programs......Page 84
Creating and Compiling a Shader......Page 85
Creating and Linking a Program......Page 89
Getting and Setting Uniforms......Page 94
Shader Compiler and Shader Binaries......Page 99
5. OpenGL ES Shading Language......Page 103
Variables and Variable Types......Page 104
Variable Constructors......Page 105
Vector and Matrix Components......Page 107
Structures......Page 108
Arrays......Page 109
Operators......Page 110
Functions......Page 111
Built-In Functions......Page 112
Control Flow Statements......Page 113
Uniforms......Page 114
Attributes......Page 115
Varyings......Page 116
Preprocessor and Directives......Page 118
Uniform and Varying Packing......Page 120
Precision Qualifiers......Page 122
Invariance......Page 123
6. Vertex Attributes, Vertex Arrays, and Buffer Objects......Page 127
Constant Vertex Attribute......Page 128
Vertex Arrays......Page 129
Declaring Vertex Attribute Variables in a Vertex Shader......Page 136
Binding Vertex Attributes to Attribute Variables in a Vertex Shader......Page 139
Vertex Buffer Objects......Page 141
Mapping Buffer Objects......Page 150
Performance Tip......Page 151
Primitives......Page 153
Triangles......Page 154
Lines......Page 155
Point Sprites......Page 156
Drawing Primitives......Page 157
Performance Tips......Page 160
Primitive Assembly......Page 162
Coordinate Systems......Page 163
Clipping......Page 164
Perspective Division......Page 165
Viewport Transformation......Page 166
Rasterization......Page 167
Culling......Page 168
Polygon Offset......Page 169
8. Vertex Shaders......Page 173
Vertex Shader Overview......Page 174
Vertex Shader Built-In Variables......Page 175
ES 2.0 Vertex Shader Limitations......Page 178
Vertex Shader Examples......Page 185
Lighting in a Vertex Shader......Page 186
Generating Texture Coordinates......Page 193
Vertex Skinning......Page 194
OpenGL ES 1.1 Vertex Pipeline as an ES 2.0 Vertex Shader......Page 199
Texturing Basics......Page 206
2D Textures......Page 207
Cubemap Textures......Page 208
Texture Objects and Loading Textures......Page 209
Texture Filtering and Mipmapping......Page 213
Automatic Mipmap Generation......Page 218
Texture Coordinate Wrapping......Page 219
Using Textures in the Fragment Shader......Page 221
Example of Using a Cubemap Texture......Page 223
Compressed Textures......Page 226
Texture Subimage Specification......Page 227
Copying Texture Data from the Color Buffer......Page 229
3D Textures......Page 232
Floating-Point Textures......Page 238
Non-Power-of-Two Textures......Page 239
10. Fragment Shaders......Page 240
Fixed Function Fragment Shaders......Page 241
Fragment Shader Overview......Page 243
Built-In Special Variables......Page 244
Built-In Constants......Page 245
ES 2.0 Fragment Shader Limitations......Page 246
Multitexturing......Page 247
Fog......Page 249
Alpha Test (Using Discard)......Page 252
User Clip Planes......Page 254
11. Fragment Operations......Page 257
Buffers......Page 258
Clearing Buffers......Page 259
Using Masks to Control Writing to Framebuffers......Page 260
Fragment Tests and Operations......Page 262
Using the Scissor Test......Page 263
Stencil Buffer Testing......Page 264
Depth Buffer Testing......Page 269
Blending......Page 270
Multisampled Antialiasing......Page 273
Reading and Writing Pixels to the Framebuffer......Page 274
Why Framebuffer Objects?......Page 277
Framebuffer and Renderbuffer Objects......Page 279
Choosing a Renderbuffer Versus a Texture as a Framebuffer Attachment......Page 280
Framebuffer Objects Versus EGL Surfaces......Page 281
Creating Framebuffer and Renderbuffer Objects......Page 282
Using Renderbuffer Objects......Page 283
Using Framebuffer Objects......Page 286
Attaching a Renderbuffer as a Framebuffer Attachment......Page 287
Attaching a 2D Texture as a Framebuffer Attachment......Page 288
Attaching an Image of a 3D Texture as a Framebuffer Attachment......Page 290
Checking for Framebuffer Completeness......Page 291
Deleting Framebuffer and Renderbuffer Objects......Page 293
Reading Pixels and Framebuffer Objects......Page 294
Examples......Page 295
Performance Tips and Tricks......Page 301
Per-Fragment Lighting......Page 303
Lighting with a Normal Map......Page 304
Lighting Shaders......Page 305
Lighting Equations......Page 309
Environment Mapping......Page 310
Particle System Setup......Page 314
Particle System Vertex Shader......Page 315
Particle System Fragment Shader......Page 317
Image Postprocessing......Page 320
Blur Fragment Shader......Page 321
Light Bloom......Page 322
Projective Texturing......Page 324
Projective Texturing Basics......Page 325
Matrices for Projective Texturing......Page 327
Projective Spotlight Shaders......Page 328
Noise Using a 3D Texture......Page 331
Generating Noise......Page 332
Using Noise......Page 337
Procedural Texturing......Page 339
A Procedural Texture Example......Page 340
Antialiasing of Procedural Textures......Page 343
Further Reading on Procedural Textures......Page 346
OpenGL ES 2.0 Implementation String Queries......Page 347
Querying Implementation-Dependent Limits......Page 348
Querying OpenGL ES State......Page 351
Hints......Page 354
Entity Name Queries......Page 355
Nonprogrammable Operations Control and Queries......Page 356
Shader and Program State Queries......Page 357
Vertex Attribute Queries......Page 359
Texture State Queries......Page 360
Renderbuffer and Framebuffer State Queries......Page 361
Handheld Platforms Overview......Page 363
Online Resources......Page 364
C++ Portability......Page 365
OpenKODE......Page 367
Platform-Specific Shader Binaries......Page 374
Targeting Extensions......Page 375
A. GL_HALF_FLOAT_OES......Page 377
16-Bit Floating-Point Number......Page 378
Converting Float to Half-Float......Page 379
B. Built-In Functions......Page 381
Angle and Trigonometry Functions......Page 382
Exponential Functions......Page 384
Common Functions......Page 385
Geometric Functions......Page 388
Matrix Functions......Page 390
Vector Relational Functions......Page 391
Texture Lookup Functions......Page 393
Derivative Functions......Page 395
C. Shading Language Grammar......Page 398
Framework Core Functions......Page 407
Transformation Functions......Page 412
A......Page 417
C......Page 418
D......Page 420
E......Page 421
F......Page 423
G......Page 425
H......Page 428
L......Page 429
M......Page 430
O......Page 431
P......Page 432
R......Page 433
S......Page 434
T......Page 435
U......Page 436
V......Page 437
W......Page 438
Z......Page 439