وبلاگ بلیان

OpenGL ES 3.0 Programming Guide, 2nd Edition

جلد کتاب OpenGL ES 3.0 Programming Guide, 2nd Edition

معرفی کتاب «OpenGL ES 3.0 Programming Guide, 2nd Edition» نوشتهٔ James Rickards و Daniel Ginsburg; Budirijanto Purnomo; Dave Shreiner; Aaftab Munshi، منتشرشده توسط نشر Addison-Wesley Professional در سال 2014. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

OpenGL (R) ES (TM) is the industry's leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. The newest version, OpenGL ES 3.0, makes it possible to create stunning visuals for new games and apps, without compromising device performance or battery life. In the (R) (TM) the authors cover the entire API and Shading Language. They carefully introduce OpenGL ES 3.0 features such as shadow mapping, instancing, multiple render targets, uniform buffer objects, texture compression, program binaries, and transform feedback. Through detailed, downloadable C-based code examples, you'll learn how to set up and program every aspect of the graphics pipeline. Step by step, you'll move from introductory techniques all the way to advanced per-pixel lighting and particle systems. Throughout, you'll find cutting-edge tips for optimizing performance, maximizing efficiency with both the API and hardware, and fully leveraging OpenGL ES 3.0 in a wide spectrum of applications. All code has been built and tested on iOS 7, Android 4.3, Windows (OpenGL ES 3.0 Emulation), and Ubuntu Linux, and the authors demonstrate how to build OpenGL ES code for each platform. c EGL API: communicating with the native windowing system, choosing configurations, and creating rendering contexts and surfaces Shaders: creating and attaching shader objects; compiling shaders; checking for compile errors; creating, linking, and querying program objects; and using source shaders and program binaries OpenGL ES Shading Language: variables, types, constructors, structures, arrays, attributes, uniform blocks, I/O variables, precision qualifiers, and invariance Geometry, vertices, and primitives: inputting geometry into the pipeline, and assembling it into primitives 2D/3D, Cubemap, Array texturing: creation, loading, and rendering; texture wrap modes, filtering, and formats; compressed textures, sampler objects, immutable textures, pixel unpack buffer objects, and mipmapping Fragment shaders: multitexturing, fog, alpha test, and user clip planes Fragment operations: scissor, stencil, and depth tests; multisampling, blending, and dithering Framebuffer objects: rendering to offscreen surfaces for advanced effects Advanced rendering: per-pixel lighting, environment mapping, particle systems, image post-processing, procedural textures, shadow mapping, terrain, and projective texturing Sync objects and fences: synchronizing within host application and GPU execution This edition of the book includes a color insert of the OpenGL ES 3.0 API and OpenGL ES Shading Language 3.0 Reference Cards created by Khronos. The reference cards contain a complete list of all of the functions in OpenGL ES 3.0 along with all of the types, operators, qualifiers, built-ins, and functions in the OpenGL ES Shading Language. Contents 8 List of Figures 18 List of Examples 22 List of Tables 26 Foreword 30 Preface 32 Intended Audience 32 Organization of This Book 33 Example Code and Shaders 37 Errata 37 Acknowledgments 38 About the Authors 40 1. Introduction to OpenGL ES 3.0 42 OpenGL ES 3.0 44 Vertex Shader 45 Primitive Assembly 48 Rasterization 48 Fragment Shader 49 Per-Fragment Operations 50 What’s New in OpenGL ES 3.0 52 Texturing 52 Shaders 54 Geometry 56 Buffer Objects 57 Framebuffer 58 OpenGL ES 3.0 and Backward Compatibility 58 EGL 60 Programming with OpenGL ES 3.0 61 Libraries and Include Files 61 EGL Command Syntax 61 OpenGL ES Command Syntax 62 Error Handling 63 Basic State Management 64 Further Reading 66 2. Hello Triangle: An OpenGL ES 3.0 Example 68 Code Framework 69 Where to Download the Examples 69 Hello Triangle Example 70 Using the OpenGL ES 3.0 Framework 75 Creating a Simple Vertex and Fragment Shader 76 Compiling and Loading the Shaders 77 Creating a Program Object and Linking the Shaders 79 Setting the Viewport and Clearing the Color Buffer 80 Loading the Geometry and Drawing a Primitive 81 Displaying the Back Buffer 82 Summary 83 3. An Introduction to EGL 84 Communicating with the Windowing System 85 Checking for Errors 86 Initializing EGL 87 Determining the Available Surface Configurations 87 Querying EGLConfig Attributes 89 Letting EGL Choose the Configuration 92 Creating an On-Screen Rendering Area: The EGL Window 94 Creating an Off-Screen Rendering Area: EGL Pbuffers 97 Creating a Rendering Context 101 Making an EGLContext Current 103 Putting All Our EGL Knowledge Together 104 Synchronizing Rendering 107 Summary 108 4. Shaders and Programs 110 Shaders and Programs 110 Creating and Compiling a Shader 111 Creating and Linking a Program 115 Uniforms and Attributes 121 Getting and Setting Uniforms 122 Uniform Buffer Objects 128 Getting and Setting Attributes 133 Shader Compiler 134 Program Binaries 135 Summary 136 5. OpenGL ES Shading Language 138 OpenGL ES Shading Language Basics 139 Shader Version Specification 139 Variables and Variable Types 140 Variable Constructors 141 Vector and Matrix Components 142 Constants 143 Structures 144 Arrays 145 Operators 145 Functions 147 Built-In Functions 148 Control Flow Statements 148 Uniforms 149 Uniform Blocks 150 Vertex and Fragment Shader Inputs/Outputs 152 Interpolation Qualifiers 155 Preprocessor and Directives 156 Uniform and Interpolator Packing 158 Precision Qualifiers 160 Invariance 162 Summary 164 6. Vertex Attributes, Vertex Arrays, and Buffer Objects 166 Specifying Vertex Attribute Data 167 Constant Vertex Attribute 167 Vertex Arrays 167 Declaring Vertex Attribute Variables in a Vertex Shader 176 Binding Vertex Attributes to Attribute Variables in a Vertex Shader 178 Vertex Buffer Objects 181 Vertex Array Objects 191 Mapping Buffer Objects 195 Flushing a Mapped Buffer 199 Copying Buffer Objects 200 Summary 201 7. Primitive Assembly and Rasterization 202 Primitives 202 Triangles 203 Lines 204 Point Sprites 205 Drawing Primitives 206 Primitive Restart 209 Provoking Vertex 210 Geometry Instancing 210 Performance Tips 213 Primitive Assembly 215 Coordinate Systems 216 Perspective Division 219 Viewport Transformation 219 Rasterization 220 Culling 221 Polygon Offset 222 Occlusion Queries 224 Summary 226 8. Vertex Shaders 228 Vertex Shader Overview 229 Vertex Shader Built-In Variables 230 Precision Qualifiers 233 Number of Uniforms Limitations in a Vertex Shader 234 Vertex Shader Examples 237 Matrix Transformations 237 Lighting in a Vertex Shader 240 Generating Texture Coordinates 246 Vertex Skinning 248 Transform Feedback 252 Vertex Textures 255 OpenGL ES 1.1 Vertex Pipeline as an ES 3.0 Vertex Shader 256 Summary 264 9. Texturing 266 Texturing Basics 267 2D Textures 267 Cubemap Textures 269 3D Textures 270 2D Texture Arrays 271 Texture Objects and Loading Textures 271 Texture Filtering and Mipmapping 278 Automatic Mipmap Generation 283 Texture Coordinate Wrapping 284 Texture Swizzles 285 Texture Level of Detail 286 Depth Texture Compare (Percentage Closest Filtering) 286 Texture Formats 287 Using Textures in a Shader 296 Example of Using a Cubemap Texture 299 Loading 3D Textures and 2D Texture Arrays 301 Compressed Textures 303 Texture Subimage Specification 307 Copying Texture Data from the Color Buffer 310 Sampler Objects 314 Immutable Textures 317 Pixel Unpack Buffer Objects 318 Summary 319 10. Fragment Shaders 320 Fixed-Function Fragment Shaders 321 Fragment Shader Overview 323 Built-In Special Variables 324 Built-In Constants 325 Precision Qualifiers 326 Implementing Fixed-Function Techniques Using Shaders 327 Multitexturing 327 Fog 329 Alpha Test (Using Discard) 332 User Clip Planes 334 Summary 336 11. Fragment Operations 338 Buffers 339 Requesting Additional Buffers 340 Clearing Buffers 340 Using Masks to Control Writing to Framebuffers 342 Fragment Tests and Operations 344 Using the Scissor Test 345 Stencil Buffer Testing 346 Blending 352 Dithering 355 Multisampled Anti-Aliasing 355 Centroid Sampling 357 Reading and Writing Pixels to the Framebuffer 357 Pixel Pack Buffer Objects 361 Multiple Render Targets 361 Summary 365 12. Framebuffer Objects 366 Why Framebuffer Objects? 366 Framebuffer and Renderbuffer Objects 368 Choosing a Renderbuffer Versus a Texture as a Framebuffer Attachment 369 Framebuffer Objects Versus EGL Surfaces 370 Creating Framebuffer and Renderbuffer Objects 370 Using Renderbuffer Objects 371 Multisample Renderbuffers 374 Renderbuffer Formats 374 Using Framebuffer Objects 376 Attaching a Renderbuffer as a Framebuffer Attachment 378 Attaching a 2D Texture as a Framebuffer Attachment 379 Attaching an Image of a 3D Texture as a Framebuffer Attachment 380 Checking for Framebuffer Completeness 382 Framebuffer Blits 383 Framebuffer Invalidation 385 Deleting Framebuffer and Renderbuffer Objects 387 Deleting Renderbuffer Objects That Are Used as Framebuffer Attachments 388 Reading Pixels and Framebuffer Objects 388 Examples 389 Performance Tips and Tricks 395 Summary 396 13. Sync Objects and Fences 398 Flush and Finish 398 Why Use a Sync Object? 399 Creating and Deleting a Sync Object 399 Waiting for and Signaling a Sync Object 400 Example 401 Summary 402 14. Advanced Programming with OpenGL ES 3.0 404 Per-Fragment Lighting 404 Lighting with a Normal Map 405 Lighting Shaders 407 Lighting Equations 410 Environment Mapping 411 Particle System with Point Sprites 415 Particle System Setup 415 Particle System Vertex Shader 416 Particle System Fragment Shader 418 Particle System Using Transform Feedback 421 Particle System Rendering Algorithm 422 Particle Emission with Transform Feedback 422 Rendering the Particles 426 Image Postprocessing 428 Render-to-Texture Setup 428 Blur Fragment Shader 429 Projective Texturing 431 Projective Texturing Basics 432 Matrices for Projective Texturing 433 Projective Spotlight Shaders 435 Noise Using a 3D Texture 438 Generating Noise 438 Using Noise 443 Procedural Texturing 445 A Procedural Texture Example 446 Anti-Aliasing of Procedural Textures 448 Further Reading on Procedural Textures 451 Rendering Terrain with Vertex Texture Fetch 451 Generating a Square Terrain Grid 452 Computing Vertex Normal and Fetching Height Value in Vertex Shader 453 Further Reading on Large Terrain Rendering 454 Shadows Using a Depth Texture 455 Rendering from the Light Position Into a Depth Texture 456 Rendering from the Eye Position with the Depth Texture 459 Summary 461 15. State Queries 462 OpenGL ES 3.0 Implementation String Queries 462 Querying Implementation-Dependent Limits 464 Querying OpenGL ES State 470 Hints 476 Entity Name Queries 477 Nonprogrammable Operations Control and Queries 477 Shader and Program State Queries 479 Vertex Attribute Queries 481 Texture State Queries 482 Sampler Queries 483 Asynchronous Object Queries 483 Sync Object Queries 484 Vertex Buffer Queries 485 Renderbuffer and Framebuffer State Queries 486 Summary 487 16. OpenGL ES Platforms 488 Building for Microsoft Windows with Visual Studio 488 Building for Ubuntu Linux 490 Building for Android 4.3+ NDK (C++) 491 Prerequisites 492 Building the Example Code with Android NDK 493 Building for Android 4.3+ SDK (Java) 493 Building for iOS 7 494 Prerequisites 494 Building the Example Code with Xcode 5 494 Summary 496 A. GL_HALF_FLOAT 498 16-Bit Floating-Point Number 499 Converting a Float to a Half-Float 500 B. Built-In Functions 504 Angle and Trigonometry Functions 506 Exponential Functions 507 Common Functions 508 Floating-Point Pack and Unpack Functions 512 Geometric Functions 513 Matrix Functions 515 Vector Relational Functions 516 Texture Lookup Functions 517 Fragment Processing Functions 524 C. ES Framework API 526 Framework Core Functions 526 Transformation Functions 531 Index 536 A 536 B 537 C 538 D 539 E 539 F 541 G 542 H 546 I 547 J 547 K 547 L 547 M 548 N 548 O 549 P 549 Q 551 R 551 S 552 T 553 U 555 V 555 W 556 Z 557 www.it-ebooks.info OpenGL ® ES TM is the industry's leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. The newest version, OpenGL ES 3.0, makes it possible to create stunning visuals for new games and apps, without compromising device performance or battery life. In the OpenGL® ESTM 3.0 Programming Guide, Second Edition, the authors cover the entire API and Shading Language. They carefully introduce OpenGL ES 3.0 features such as shadow mapping, instancing, multiple render targets, uniform buffer objects, texture compression, program binaries, and transform feedback. Through detailed, downloadable C-based code examples, you'll learn how to set up and program every aspect of the graphics pipeline. Step by step, you'll move from introductory techniques all the way to advanced per-pixel lighting and particle systems. Throughout, you'll find cutting-edge tips for optimizing performance, maximizing efficiency with both the API and hardware, and fully leveraging OpenGL ES 3.0 in a wide spectrum of applications. All code has been built and tested on iOS 7, Android 4.3, Windows (OpenGL ES 3.0 Emulation), and Ubuntu Linux, and the authors demonstrate how to build OpenGL ES code for each platform. Coverage includes EGL API: communicating with the native windowing system, choosing configurations, and creating rendering contexts and surfaces Shaders: creating and attaching shader objects; compiling shaders; checking for compile errors; creating, linking, and querying program objects; and using source shaders and program binaries OpenGL ES Shading Language: variables, types, constructors, structures, arrays, attributes, uniform blocks, I/O variables, precision qualifiers, and invariance Geometry, vertices, and primitives: inputting geometry into the pipeline, and assembling it into primitives 2D/3D, Cubemap, Array texturing: creation, loading, and rendering; texture wrap modes, filtering, and formats; compressed textures, sampler objects, immutable textures, pixel unpack buffer objects, and mipmapping Fragment shaders: multitexturing, fog, alpha test, and user clip planes Fragment operations: scissor, stencil, and depth tests; multisampling, blending, and dithering Framebuffer objects: rendering to offscreen surfaces for advanced effects Advanced rendering: per-pixel lighting, environment mapping, particle systems, image post-processing, procedural textures, shadow mapping, terrain, and projective texturing Sync objects and fences: synchronizing within host application and GPU execution This edition of the book includes a color insert of the OpenGL ES 3.0 API and OpenGL ES Shading Language 3.0 Reference Cards created by Khronos. The reference cards contain a complete list of all of the functions in OpenGL ES 3.0 along with all of the types, operators, qualifiers, built-ins, and functions in the OpenGL ES Shading Language. OpenGL® ES is the industry's leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. The newest version, OpenGL ES 3.0, makes it possible to create stunning visuals for new games and apps, without compromising device performance or battery life. In the OpenGL ® ES 3.0 Programming Guide, Second Edition, the authors cover the entire API and Shading Language. They carefully introduce OpenGL ES 3.0 features such as shadow mapping, instancing, multiple render targets, uniform buffer objects, texture compression, program binaries, and transform feedback. Through detailed, downloadable C-based code examples, you'll learn how to set up and program every aspect of the graphics pipeline. Step by step, you'll move from introductory techniques all the way to advanced per-pixel lighting and particle systems. Throughout, you'll find cutting-edge tips for optimizing performance, maximizing efficiency with both the API and hardware, and fully leveraging OpenGL ES 3.0 in a wide spectrum of applications. All code has been built and tested on iOS 7, Android 4.3, Windows (OpenGL ES 3.0 Emulation), and Ubuntu Linux, and the authors demonstrate how to build OpenGL ES code for each platform. Coverage in c ludes EGL API: communicating with the native windowing system, choosing configurations, and creating rendering contexts and surfaces Shaders: creating and attaching shader objects; compiling shaders; checking for compile errors; creating, linking, and querying program objects; and using source shaders and program binaries OpenGL ES Shading Language: variables, types, constructors, structures, arrays, attributes, uniform blocks, I/O variables, precision qualifiers, and invariance Geometry, vertices, and primitives: inputting geometry into the pipeline, and assembling it into primitives 2D/3D, Cubemap, Array texturing: creation, loading, and rendering; texture wrap modes, filtering, and formats; compressed textures, sampler objects, immutable textures, pixel unpack buffer objects, and mipmapping Fragment shaders: multitexturing, fog, alpha test, and user clip planes Fragment operations: scissor, stencil, and depth tests; multisampling, blending, and dithering Framebuffer objects: rendering to offscreen surfaces for advanced effects Advanced rendering: per-pixel lighting, environment mapping, particle systems, image post-processing, procedural textures, shadow mapping, terrain, and projective textures OpenGL ES TM is the industrys leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. The newest version, OpenGL ES 3.0, makes it possible to create stunning visuals for new games and apps, without compromising device performance or battery life. In the OpenGL ES TM 3.0 Programming Guide, Second Edition, the authors cover the entire API and Shading Language. They carefully introduce OpenGL ES 3.0 features such as shadow mapping, instancing, multiple render targets, uniform buffer objects, texture compression, program binaries, and transform feedback. Through detailed, downloadable C-based code examples, youll learn how to set up and program every aspect of the graphics pipeline. Step by step, youll move from introductory techniques all the way to advanced per-pixel lighting and particle systems. Throughout, youll find cutting-edge tips for optimizing performance, maximizing efficiency with both the API and hardware, and fully leveraging OpenGL ES 3.0 in a wide spectrum of applications. All code has been built and tested on iOS 7, Android 4.3, Windows (OpenGL ES 3.0 Emulation), and Ubuntu Linux, and the authors demonstrate how to build OpenGL ES code for each platform. Coverage in c ludes This edition of the book includes a color insert of the OpenGL ES 3.0 API and OpenGL ES Shading Language 3.0 Reference Cards created by Khronos. The reference cards contain a complete list of all of the functions in OpenGL ES 3.0 along with all of the types, operators, qualifiers, built-ins, and functions in the OpenGL ES Shading Language. OpenGL ES 3.0 is the industry's leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices. In the OpenGL ES 3.0 Programming Guide, leading authorities on the OpenGL ES interface provide start-to-finish guidance on the new 3.0 release and how how to maximize its use in a wide range of high-performance applications. Developers creating 3D handheld games, user interfaces, or applications using OpenGL ES 3.0 will want to read the OpenGL ES 3.0 Programming Guide. This book focuses on the OpenGL ES 3.0 pipeline (the API and the shading language), and shows how to develop applications for OpenGL ES 3.0 via examples, descriptions, and best-practices. The OpenGL ES 3.0 specification contains many new features that are covered in this 2nd edition of the book
دانلود کتاب OpenGL ES 3.0 Programming Guide, 2nd Edition