وبلاگ بلیان

The OpenGL ES 2.0 programming guide

معرفی کتاب «The OpenGL ES 2.0 programming guide» نوشتهٔ Ginsburg, Dan;Munshi, Aaftab;Shreiner, Dave، منتشرشده توسط نشر Addison-Wesley Professional در سال 2012. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

This is the eBook version of the printed book. If the print book includes a CD-ROM, this content is not included within the eBook version.OpenGL ES 2.0 is the industry's leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. With OpenGL ES 2.0, the full programmability of shaders is now available on small and portable devices—including cell phones, PDAs, consoles, appliances, and vehicles. However, OpenGL ES differs significantly from OpenGL. Graphics programmers and mobile developers have had very little information about it—until now. In the OpenGL® ES 2.0 Programming Guide, three leading authorities on the Open GL ES 2.0 interface—including the specification's editor—provide start-to-finish guidance for maximizing the interface's value in a wide range of high-performance applications. The authors cover the entire API, including Khronos-ratified extensions. Using detailed C-based code examples, they demonstrate how to set up and program every aspect of the graphics pipeline. You'll move from introductory techniques all the way to advanced per-pixel lighting, particle systems, and performance optimization. Coverage includes: Shaders in depth: creating shader objects, compiling shaders, checking for compile errors, attaching shader objects to program objects, and linking final program objects The OpenGL ES Shading Language: variables, types, constructors, structures, arrays, attributes, uniforms, varyings, precision qualifiers, and invariance Inputting geometry into the graphics pipeline, and assembling geometry into primitives Vertex shaders, their special variables, and their use in per-vertex lighting, skinning, and other applications Using fragment shaders—including examples of multitexturing, fog, alpha test, and user clip planes Fragment operations: scissor test, stencil test, depth test, multisampling, blending, and dithering Advanced rendering: per-pixel lighting with normal maps, environment mapping, particle systems, image post-processing, and projective texturing Real-world programming challenges: platform diversity, C++ portability, OpenKODE, and platform-specific shader binaries The OpenGL ES 2.0 programming guide......Page 1 Contents......Page 6 List of Figures......Page 14 List of Examples......Page 16 List of Tables......Page 20 Foreword......Page 22 Intended Audience......Page 24 Organization of the Book......Page 25 Errata......Page 29 Acknowledgments......Page 30 About the Authors......Page 32 What Is OpenGL ES?......Page 34 OpenGL ES 2.0......Page 36 Vertex Shader......Page 37 Primitive Assembly......Page 39 Fragment Shader......Page 40 Per-Fragment Operations......Page 42 OpenGL ES 2.0 and OpenGL ES 1.x Backward Compatibility......Page 44 EGL......Page 45 Libraries and Include Files......Page 46 OpenGL ES Command Syntax......Page 47 Error Handling......Page 48 Flush and Finish......Page 49 Basic State Management......Page 50 Further Reading......Page 51 2. Hello Triangle: An OpenGL ES 2.0 Example......Page 52 Where to Download the Examples......Page 53 Hello Triangle Example......Page 54 Building and Running the Examples......Page 58 Using the OpenGL ES 2.0 Framework......Page 59 Creating a Simple Vertex and Fragment Shader......Page 60 Compiling and Loading the Shaders......Page 62 Creating a Program Object and Linking the Shaders......Page 63 Setting the Viewport and Clearing the Color Buffer......Page 65 Displaying the Back Buffer......Page 66 3. An Introduction to EGL......Page 68 Communicating with the Windowing System......Page 69 Initializing EGL......Page 70 Determining the Available Surface Configurations......Page 71 Letting EGL Choose the Config......Page 72 Creating an On-Screen Rendering Area: The EGL Window......Page 76 Creating an Off-Screen Rendering Area: EGL Pbuffers......Page 79 Creating a Rendering Context......Page 83 Putting All Our EGL Knowledge Together......Page 85 Synchronizing Rendering......Page 87 Shaders and Programs......Page 90 Creating and Compiling a Shader......Page 91 Creating and Linking a Program......Page 95 Getting and Setting Uniforms......Page 100 Shader Compiler and Shader Binaries......Page 105 5. OpenGL ES Shading Language......Page 110 Variables and Variable Types......Page 111 Variable Constructors......Page 112 Vector and Matrix Components......Page 114 Structures......Page 115 Arrays......Page 116 Operators......Page 117 Functions......Page 118 Built-In Functions......Page 119 Control Flow Statements......Page 120 Uniforms......Page 121 Attributes......Page 122 Varyings......Page 123 Preprocessor and Directives......Page 125 Uniform and Varying Packing......Page 127 Precision Qualifiers......Page 129 Invariance......Page 130 6. Vertex Attributes, Vertex Arrays, and Buffer Objects......Page 134 Constant Vertex Attribute......Page 135 Vertex Arrays......Page 136 Declaring Vertex Attribute Variables in a Vertex Shader......Page 143 Binding Vertex Attributes to Attribute Variables in a Vertex Shader......Page 146 Vertex Buffer Objects......Page 148 Mapping Buffer Objects......Page 157 Performance Tip......Page 158 Primitives......Page 160 Triangles......Page 161 Lines......Page 162 Point Sprites......Page 163 Drawing Primitives......Page 164 Performance Tips......Page 167 Primitive Assembly......Page 169 Coordinate Systems......Page 170 Clipping......Page 171 Perspective Division......Page 172 Viewport Transformation......Page 173 Rasterization......Page 174 Culling......Page 175 Polygon Offset......Page 176 8. Vertex Shaders......Page 180 Vertex Shader Overview......Page 181 Vertex Shader Built-In Variables......Page 182 ES 2.0 Vertex Shader Limitations......Page 185 Vertex Shader Examples......Page 192 Lighting in a Vertex Shader......Page 193 Generating Texture Coordinates......Page 200 Vertex Skinning......Page 201 OpenGL ES 1.1 Vertex Pipeline as an ES 2.0 Vertex Shader......Page 206 Texturing Basics......Page 214 2D Textures......Page 215 Cubemap Textures......Page 216 Texture Objects and Loading Textures......Page 217 Texture Filtering and Mipmapping......Page 221 Automatic Mipmap Generation......Page 226 Texture Coordinate Wrapping......Page 227 Using Textures in the Fragment Shader......Page 229 Example of Using a Cubemap Texture......Page 231 Compressed Textures......Page 234 Texture Subimage Specification......Page 235 Copying Texture Data from the Color Buffer......Page 237 3D Textures......Page 240 Floating-Point Textures......Page 246 Non-Power-of-Two Textures......Page 247 10. Fragment Shaders......Page 248 Fixed Function Fragment Shaders......Page 249 Fragment Shader Overview......Page 251 Built-In Special Variables......Page 252 Built-In Constants......Page 253 ES 2.0 Fragment Shader Limitations......Page 254 Multitexturing......Page 255 Fog......Page 257 Alpha Test (Using Discard)......Page 260 User Clip Planes......Page 262 11. Fragment Operations......Page 266 Buffers......Page 267 Clearing Buffers......Page 268 Using Masks to Control Writing to Framebuffers......Page 269 Fragment Tests and Operations......Page 271 Using the Scissor Test......Page 272 Stencil Buffer Testing......Page 273 Depth Buffer Testing......Page 278 Blending......Page 279 Multisampled Antialiasing......Page 282 Reading and Writing Pixels to the Framebuffer......Page 283 Why Framebuffer Objects?......Page 286 Framebuffer and Renderbuffer Objects......Page 288 Choosing a Renderbuffer Versus a Texture as a Framebuffer Attachment......Page 289 Framebuffer Objects Versus EGL Surfaces......Page 290 Creating Framebuffer and Renderbuffer Objects......Page 291 Using Renderbuffer Objects......Page 292 Using Framebuffer Objects......Page 295 Attaching a Renderbuffer as a Framebuffer Attachment......Page 296 Attaching a 2D Texture as a Framebuffer Attachment......Page 297 Attaching an Image of a 3D Texture as a Framebuffer Attachment......Page 299 Checking for Framebuffer Completeness......Page 300 Deleting Framebuffer and Renderbuffer Objects......Page 302 Reading Pixels and Framebuffer Objects......Page 303 Examples......Page 304 Performance Tips and Tricks......Page 310 Per-Fragment Lighting......Page 312 Lighting with a Normal Map......Page 313 Lighting Shaders......Page 314 Lighting Equations......Page 318 Environment Mapping......Page 319 Particle System Setup......Page 323 Particle System Vertex Shader......Page 324 Particle System Fragment Shader......Page 326 Image Postprocessing......Page 329 Blur Fragment Shader......Page 330 Light Bloom......Page 331 Projective Texturing......Page 333 Projective Texturing Basics......Page 334 Matrices for Projective Texturing......Page 336 Projective Spotlight Shaders......Page 337 Noise Using a 3D Texture......Page 340 Generating Noise......Page 341 Using Noise......Page 346 Procedural Texturing......Page 348 A Procedural Texture Example......Page 349 Antialiasing of Procedural Textures......Page 352 Further Reading on Procedural Textures......Page 355 OpenGL ES 2.0 Implementation String Queries......Page 356 Querying Implementation-Dependent Limits......Page 357 Querying OpenGL ES State......Page 360 Hints......Page 363 Entity Name Queries......Page 364 Nonprogrammable Operations Control and Queries......Page 365 Shader and Program State Queries......Page 366 Vertex Attribute Queries......Page 368 Texture State Queries......Page 369 Renderbuffer and Framebuffer State Queries......Page 370 Handheld Platforms Overview......Page 372 Online Resources......Page 373 C++ Portability......Page 374 OpenKODE......Page 376 Platform-Specific Shader Binaries......Page 383 Targeting Extensions......Page 384 A. GL_HALF_FLOAT_OES......Page 386 16-Bit Floating-Point Number......Page 387 Converting Float to Half-Float......Page 388 B. Built-In Functions......Page 390 Angle and Trigonometry Functions......Page 391 Exponential Functions......Page 393 Common Functions......Page 394 Geometric Functions......Page 397 Matrix Functions......Page 399 Vector Relational Functions......Page 400 Texture Lookup Functions......Page 402 Derivative Functions......Page 404 C. Shading Language Grammar......Page 408 Framework Core Functions......Page 418 Transformation Functions......Page 423 A......Page 428 C......Page 429 D......Page 431 E......Page 432 F......Page 434 G......Page 436 H......Page 439 L......Page 440 M......Page 441 O......Page 442 P......Page 443 R......Page 444 S......Page 445 T......Page 446 U......Page 447 V......Page 448 W......Page 449 Z......Page 450 The OpenGL ES 2.0 programming guide 1 Contents 6 List of Figures 14 List of Examples 16 List of Tables 20 Foreword 22 Preface 24 Intended Audience 24 Organization of the Book 25 Example Code and Shaders 29 Errata 29 Acknowledgments 30 About the Authors 32 1. Introduction to OpenGL ES 2.0 34 What Is OpenGL ES? 34 OpenGL ES 2.0 36 Vertex Shader 37 Primitive Assembly 39 Rasterization 40 Fragment Shader 40 Per-Fragment Operations 42 OpenGL ES 2.0 and OpenGL ES 1.x Backward Compatibility 44 EGL 45 Programming with OpenGL ES 2.0 46 Libraries and Include Files 46 EGL Command Syntax 47 OpenGL ES Command Syntax 47 Error Handling 48 Flush and Finish 49 Basic State Management 50 Further Reading 51 2. Hello Triangle: An OpenGL ES 2.0 Example 52 Code Framework 53 Where to Download the Examples 53 Hello Triangle Example 54 Building and Running the Examples 58 Using the OpenGL ES 2.0 Framework 59 Creating a Simple Vertex and Fragment Shader 60 Compiling and Loading the Shaders 62 Creating a Program Object and Linking the Shaders 63 Setting the Viewport and Clearing the Color Buffer 65 Loading the Geometry and Drawing a Primitive 66 Displaying the Back Buffer 66 3. An Introduction to EGL 68 Communicating with the Windowing System 69 Checking for Errors 70 Initializing EGL 70 Determining the Available Surface Configurations 71 Querying EGLConfig Attributes 72 Letting EGL Choose the Config 72 Creating an On-Screen Rendering Area: The EGL Window 76 Creating an Off-Screen Rendering Area: EGL Pbuffers 79 Creating a Rendering Context 83 Making an EGLContext Current 85 Putting All Our EGL Knowledge Together 85 Synchronizing Rendering 87 4. Shaders and Programs 90 Shaders and Programs 90 Creating and Compiling a Shader 91 Creating and Linking a Program 95 Uniforms and Attributes 100 Getting and Setting Uniforms 100 Getting and Setting Attributes 105 Shader Compiler and Shader Binaries 105 5. OpenGL ES Shading Language 110 OpenGL ES Shading Language Basics 111 Variables and Variable Types 111 Variable Constructors 112 Vector and Matrix Components 114 Constants 115 Structures 115 Arrays 116 Operators 117 Functions 118 Built-In Functions 119 Control Flow Statements 120 Uniforms 121 Attributes 122 Varyings 123 Preprocessor and Directives 125 Uniform and Varying Packing 127 Precision Qualifiers 129 Invariance 130 6. Vertex Attributes, Vertex Arrays, and Buffer Objects 134 Specifying Vertex Attribute Data 135 Constant Vertex Attribute 135 Vertex Arrays 136 Declaring Vertex Attribute Variables in a Vertex Shader 143 Binding Vertex Attributes to Attribute Variables in a Vertex Shader 146 Vertex Buffer Objects 148 Mapping Buffer Objects 157 Performance Tip 158 7. Primitive Assembly and Rasterization 160 Primitives 160 Triangles 161 Lines 162 Point Sprites 163 Drawing Primitives 164 Performance Tips 167 Primitive Assembly 169 Coordinate Systems 170 Clipping 171 Perspective Division 172 Viewport Transformation 173 Rasterization 174 Culling 175 Polygon Offset 176 8. Vertex Shaders 180 Vertex Shader Overview 181 Vertex Shader Built-In Variables 182 Precision Qualifiers 185 ES 2.0 Vertex Shader Limitations 185 Vertex Shader Examples 192 A Simple Vertex Shader 193 Lighting in a Vertex Shader 193 Generating Texture Coordinates 200 Vertex Skinning 201 OpenGL ES 1.1 Vertex Pipeline as an ES 2.0 Vertex Shader 206 9. Texturing 214 Texturing Basics 214 2D Textures 215 Cubemap Textures 216 Texture Objects and Loading Textures 217 Texture Filtering and Mipmapping 221 Automatic Mipmap Generation 226 Texture Coordinate Wrapping 227 Using Textures in the Fragment Shader 229 Example of Using a Cubemap Texture 231 Compressed Textures 234 Texture Subimage Specification 235 Copying Texture Data from the Color Buffer 237 Optional Extensions 240 3D Textures 240 Ericsson Texture Compression (ETC) 246 Floating-Point Textures 246 Non-Power-of-Two Textures 247 10. Fragment Shaders 248 Fixed Function Fragment Shaders 249 Fragment Shader Overview 251 Built-In Special Variables 252 Built-In Constants 253 Precision Qualifiers 254 ES 2.0 Fragment Shader Limitations 254 Implementing Fixed Function Techniques Using Shaders 255 Multitexturing 255 Fog 257 Alpha Test (Using Discard) 260 User Clip Planes 262 11. Fragment Operations 266 Buffers 267 Requesting Additional Buffers 268 Clearing Buffers 268 Using Masks to Control Writing to Framebuffers 269 Fragment Tests and Operations 271 Using the Scissor Test 272 Stencil Buffer Testing 273 Depth Buffer Testing 278 Blending 279 Dithering 282 Multisampled Antialiasing 282 Reading and Writing Pixels to the Framebuffer 283 12. Framebuffer Objects 286 Why Framebuffer Objects? 286 Framebuffer and Renderbuffer Objects 288 Choosing a Renderbuffer Versus a Texture as a Framebuffer Attachment 289 Framebuffer Objects Versus EGL Surfaces 290 Creating Framebuffer and Renderbuffer Objects 291 Using Renderbuffer Objects 292 Using Framebuffer Objects 295 Attaching a Renderbuffer as a Framebuffer Attachment 296 Attaching a 2D Texture as a Framebuffer Attachment 297 Attaching an Image of a 3D Texture as a Framebuffer Attachment 299 Checking for Framebuffer Completeness 300 Deleting Framebuffer and Renderbuffer Objects 302 Deleting Renderbuffer Objects That Are Used as Framebuffer Attachments 303 Reading Pixels and Framebuffer Objects 303 Examples 304 Performance Tips and Tricks 310 13. Advanced Programming with OpenGL ES 2.0 312 Per-Fragment Lighting 312 Lighting with a Normal Map 313 Lighting Shaders 314 Lighting Equations 318 Environment Mapping 319 Particle System with Point Sprites 323 Particle System Setup 323 Particle System Vertex Shader 324 Particle System Fragment Shader 326 Image Postprocessing 329 Render-to-Texture Setup 330 Blur Fragment Shader 330 Light Bloom 331 Projective Texturing 333 Projective Texturing Basics 334 Matrices for Projective Texturing 336 Projective Spotlight Shaders 337 Noise Using a 3D Texture 340 Generating Noise 341 Using Noise 346 Procedural Texturing 348 A Procedural Texture Example 349 Antialiasing of Procedural Textures 352 Further Reading on Procedural Textures 355 14. State Queries 356 OpenGL ES 2.0 Implementation String Queries 356 Querying Implementation-Dependent Limits 357 Querying OpenGL ES State 360 Hints 363 Entity Name Queries 364 Nonprogrammable Operations Control and Queries 365 Shader and Program State Queries 366 Vertex Attribute Queries 368 Texture State Queries 369 Vertex Buffer Queries 370 Renderbuffer and Framebuffer State Queries 370 15. OpenGL ES and EGL on Handheld Platforms 372 Handheld Platforms Overview 372 Online Resources 373 C++ Portability 374 OpenKODE 376 Platform-Specific Shader Binaries 383 Targeting Extensions 384 A. GL_HALF_FLOAT_OES 386 16-Bit Floating-Point Number 387 Converting Float to Half-Float 388 B. Built-In Functions 390 Angle and Trigonometry Functions 391 Exponential Functions 393 Common Functions 394 Geometric Functions 397 Matrix Functions 399 Vector Relational Functions 400 Texture Lookup Functions 402 Derivative Functions 404 C. Shading Language Grammar 408 D. ES Framework API 418 Framework Core Functions 418 Transformation Functions 423 Index 428 A 428 B 429 C 429 D 431 E 432 F 434 G 436 H 439 I 440 K 440 L 440 M 441 N 442 O 442 P 443 Q 444 R 444 S 445 T 446 U 447 V 448 W 449 X 450 Z 450

opengl Es 2.0 Is The Industry’s Leading Software Interface And Graphics Library For Rendering Sophisticated 3d Graphics On Handheld And Embedded Devices. With Opengl Es 2.0, The Full Programmability Of Shaders Is Now Available On Small And Portable Devices—including Cell Phones, Pdas, Consoles, Appliances, And Vehicles. However, Opengl Es Differs Significantly From Opengl. Graphics Programmers And Mobile Developers Have Had Very Little Information About It—until Now.

in The Opengl® Es 2.0 Programming Guide, Three Leading Authorities On The Open Gl Es 2.0 Interface—including The Specification’s Editor—provide Start-to-finish Guidance For Maximizing The Interface’s Value In A Wide Range Of High-performance Applications. The Authors Cover The Entire Api, Including Khronos-ratified Extensions. Using Detailed C-based Code Examples, They Demonstrate How To Set Up And Program Every Aspect Of The Graphics Pipeline. You’ll Move From Introductory Techniques All The Way To Advanced Per-pixel Lighting, Particle Systems, And Performance Optimization. 

coverage Includes:

  • shaders In Depth: Creating Shader Objects, Compiling Shaders, Checking For Compile Errors, Attaching Shader Objects To Program Objects, And Linking Final Program Objects
  • the Opengl Es Shading Language: Variables, Types, Constructors, Structures, Arrays, Attributes, Uniforms, Varyings, Precision Qualifiers, And Invariance
  • inputting Geometry Into The Graphics Pipeline, And Assembling Geometry Into Primitives
  • vertex Shaders, Their Special Variables, And Their Use In Per-vertex Lighting, Skinning, And Other Applications
  • usingfragment Shaders—including Examples Of Multitexturing, Fog, Alpha Test, And User Clip Planes
  • fragment Operations: Scissor Test, Stencil Test, Depth Test, Multisampling, Blending, And Dithering
  • advanced Rendering: Per-pixel Lighting With Normal Maps, Environment Mapping, Particle Systems, Image Post-processing, And Projective Texturing
  • real-world Programming Challenges: Platform Diversity, C++ Portability, Openkode, And Platform-specific Shader Binaries


دانلود کتاب The OpenGL ES 2.0 programming guide