Book Description

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® ES3.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.

Table of Contents

  1. About This eBook
  2. Title Page
  3. Copyright Page
  4. Praise for OpenGL® ES™ 3.0 Programming Guide, Second Edition
  5. Contents
  6. List of Figures
  7. List of Examples
  8. List of Tables
  9. Foreword
  10. Preface
    1. Intended Audience
    2. Organization of This Book
    3. Example Code and Shaders
    4. Errata
  11. Acknowledgments
  12. About the Authors
  13. Chapter 1. Introduction to OpenGL ES 3.0
    1. OpenGL ES 3.0
    2. What’s New in OpenGL ES 3.0
    3. OpenGL ES 3.0 and Backward Compatibility
    4. EGL
    5. EGL Command Syntax
    6. OpenGL ES Command Syntax
    7. Error Handling
    8. Basic State Management
    9. Further Reading
  14. Chapter 2. Hello Triangle: An OpenGL ES 3.0 Example
    1. Code Framework
    2. Where to Download the Examples
    3. Hello Triangle Example
    4. Using the OpenGL ES 3.0 Framework
    5. Creating a Simple Vertex and Fragment Shader
    6. Compiling and Loading the Shaders
    7. Creating a Program Object and Linking the Shaders
    8. Setting the Viewport and Clearing the Color Buffer
    9. Loading the Geometry and Drawing a Primitive
    10. Displaying the Back Buffer
    11. Summary
  15. Chapter 3. An Introduction to EGL
    1. Communicating with the Windowing System
    2. Checking for Errors
    3. Initializing EGL
    4. Determining the Available Surface Configurations
    5. Querying EGLConfig Attributes
    6. Letting EGL Choose the Configuration
    7. Creating an On-Screen Rendering Area: The EGL Window
    8. Creating an Off-Screen Rendering Area: EGL Pbuffers
    9. Creating a Rendering Context
    10. Making an EGLContext Current
    11. Putting All Our EGL Knowledge Together
    12. Synchronizing Rendering
    13. Summary
  16. Chapter 4. Shaders and Programs
    1. Shaders and Programs
    2. Uniforms and Attributes
    3. Shader Compiler
    4. Program Binaries
    5. Summary
  17. Chapter 5. OpenGL ES Shading Language
    1. OpenGL ES Shading Language Basics
    2. Shader Version Specification
    3. Variables and Variable Types
    4. Variable Constructors
    5. Vector and Matrix Components
    6. Constants
    7. Structures
    8. Arrays
    9. Operators
    10. Functions
    11. Built-In Functions
    12. Control Flow Statements
    13. Uniforms
    14. Uniform Blocks
    15. Vertex and Fragment Shader Inputs/Outputs
    16. Interpolation Qualifiers
    17. Preprocessor and Directives
    18. Uniform and Interpolator Packing
    19. Precision Qualifiers
    20. Invariance
    21. Summary
  18. Chapter 6. Vertex Attributes, Vertex Arrays, and Buffer Objects
    1. Specifying Vertex Attribute Data
    2. Declaring Vertex Attribute Variables in a Vertex Shader
    3. Vertex Buffer Objects
    4. Vertex Array Objects
    5. Mapping Buffer Objects
    6. Copying Buffer Objects
    7. Summary
  19. Chapter 7. Primitive Assembly and Rasterization
    1. Primitives
    2. Drawing Primitives
    3. Primitive Assembly
    4. Rasterization
    5. Occlusion Queries
    6. Summary
  20. Chapter 8. Vertex Shaders
    1. Vertex Shader Overview
    2. Vertex Shader Examples
    3. Generating Texture Coordinates
    4. Vertex Skinning
    5. Transform Feedback
    6. Vertex Textures
    7. OpenGL ES 1.1 Vertex Pipeline as an ES 3.0 Vertex Shader
    8. Summary
  21. Chapter 9. Texturing
    1. Texturing Basics
    2. Compressed Textures
    3. Texture Subimage Specification
    4. Copying Texture Data from the Color Buffer
    5. Sampler Objects
    6. Immutable Textures
    7. Pixel Unpack Buffer Objects
    8. Summary
  22. Chapter 10. Fragment Shaders
    1. Fixed-Function Fragment Shaders
    2. Fragment Shader Overview
    3. Implementing Fixed-Function Techniques Using Shaders
    4. Summary
  23. Chapter 11. Fragment Operations
    1. Buffers
    2. Fragment Tests and Operations
    3. Blending
    4. Dithering
    5. Multisampled Anti-Aliasing
    6. Reading and Writing Pixels to the Framebuffer
    7. Multiple Render Targets
    8. Summary
  24. Chapter 12. Framebuffer Objects
    1. Why Framebuffer Objects?
    2. Framebuffer and Renderbuffer Objects
    3. Creating Framebuffer and Renderbuffer Objects
    4. Using Renderbuffer Objects
    5. Using Framebuffer Objects
    6. Framebuffer Blits
    7. Framebuffer Invalidation
    8. Deleting Framebuffer and Renderbuffer Objects
    9. Examples
    10. Performance Tips and Tricks
    11. Summary
  25. Chapter 13. Sync Objects and Fences
    1. Flush and Finish
    2. Why Use a Sync Object?
    3. Creating and Deleting a Sync Object
    4. Waiting for and Signaling a Sync Object
    5. Example
    6. Summary
  26. Chapter 14. Advanced Programming with OpenGL ES 3.0
    1. Per-Fragment Lighting
    2. Environment Mapping
    3. Particle System Using Transform Feedback
    4. Image Postprocessing
    5. Projective Texturing
    6. Noise Using a 3D Texture
    7. Procedural Texturing
    8. Rendering Terrain with Vertex Texture Fetch
    9. Shadows Using a Depth Texture
    10. Summary
  27. Chapter 15. State Queries
    1. OpenGL ES 3.0 Implementation String Queries
    2. Querying Implementation-Dependent Limits
    3. Querying OpenGL ES State
    4. Hints
    5. Entity Name Queries
    6. Nonprogrammable Operations Control and Queries
    7. Shader and Program State Queries
    8. Vertex Attribute Queries
    9. Texture State Queries
    10. Sampler Queries
    11. Asynchronous Object Queries
    12. Sync Object Queries
    13. Vertex Buffer Queries
    14. Renderbuffer and Framebuffer State Queries
    15. Summary
  28. Chapter 16. OpenGL ES Platforms
    1. Building for Microsoft Windows with Visual Studio
    2. Building for Ubuntu Linux
    3. Building for Android 4.3+ NDK (C++)
    4. Building for Android 4.3+ SDK (Java)
    5. Building for iOS 7
    6. Summary
  29. Appendix A. GL_HALF_FLOAT
    1. 16-Bit Floating-Point Number
    2. Converting a Float to a Half-Float
  30. Appendix B. Built-In Functions
    1. Angle and Trigonometry Functions
    2. Exponential Functions
    3. Common Functions
    4. Floating-Point Pack and Unpack Functions
    5. Geometric Functions
    6. Matrix Functions
    7. Vector Relational Functions
    8. Texture Lookup Functions
    9. Fragment Processing Functions
  31. Appendix C. ES Framework API
    1. Framework Core Functions
    2. Transformation Functions
  32. Index