OpenGL Es 3.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"

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 OpenGL (R) 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, 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.

Author(s): Daniel Ginsburg; Budirijanto Purnomo; Dave Shreiner; Aaftab Munshi
Edition: 2
Publisher: Addison-Wesley Professional
Year: 2014

Language: English
Pages: 560

Contents
List of Figures
List of Examples
List of Tables
Foreword
Preface
Intended Audience
Organization of This Book
Example Code and Shaders
Errata
Acknowledgments
About the Authors
1. Introduction to OpenGL ES 3.0
OpenGL ES 3.0
Vertex Shader
Primitive Assembly
Rasterization
Fragment Shader
Per-Fragment Operations
What’s New in OpenGL ES 3.0
Texturing
Shaders
Geometry
Buffer Objects
Framebuffer
OpenGL ES 3.0 and Backward Compatibility
EGL
Programming with OpenGL ES 3.0
Libraries and Include Files
EGL Command Syntax
OpenGL ES Command Syntax
Error Handling
Basic State Management
Further Reading
2. Hello Triangle: An OpenGL ES 3.0 Example
Code Framework
Where to Download the Examples
Hello Triangle Example
Using the OpenGL ES 3.0 Framework
Creating a Simple Vertex and Fragment Shader
Compiling and Loading the Shaders
Creating a Program Object and Linking the Shaders
Setting the Viewport and Clearing the Color Buffer
Loading the Geometry and Drawing a Primitive
Displaying the Back Buffer
Summary
3. An Introduction to EGL
Communicating with the Windowing System
Checking for Errors
Initializing EGL
Determining the Available Surface Configurations
Querying EGLConfig Attributes
Letting EGL Choose the Configuration
Creating an On-Screen Rendering Area: The EGL Window
Creating an Off-Screen Rendering Area: EGL Pbuffers
Creating a Rendering Context
Making an EGLContext Current
Putting All Our EGL Knowledge Together
Synchronizing Rendering
Summary
4. Shaders and Programs
Shaders and Programs
Creating and Compiling a Shader
Creating and Linking a Program
Uniforms and Attributes
Getting and Setting Uniforms
Uniform Buffer Objects
Getting and Setting Attributes
Shader Compiler
Program Binaries
Summary
5. OpenGL ES Shading Language
OpenGL ES Shading Language Basics
Shader Version Specification
Variables and Variable Types
Variable Constructors
Vector and Matrix Components
Constants
Structures
Arrays
Operators
Functions
Built-In Functions
Control Flow Statements
Uniforms
Uniform Blocks
Vertex and Fragment Shader Inputs/Outputs
Interpolation Qualifiers
Preprocessor and Directives
Uniform and Interpolator Packing
Precision Qualifiers
Invariance
Summary
6. Vertex Attributes, Vertex Arrays, and Buffer Objects
Specifying Vertex Attribute Data
Constant Vertex Attribute
Vertex Arrays
Declaring Vertex Attribute Variables in a Vertex Shader
Binding Vertex Attributes to Attribute Variables in a Vertex Shader
Vertex Buffer Objects
Vertex Array Objects
Mapping Buffer Objects
Flushing a Mapped Buffer
Copying Buffer Objects
Summary
7. Primitive Assembly and Rasterization
Primitives
Triangles
Lines
Point Sprites
Drawing Primitives
Primitive Restart
Provoking Vertex
Geometry Instancing
Performance Tips
Primitive Assembly
Coordinate Systems
Perspective Division
Viewport Transformation
Rasterization
Culling
Polygon Offset
Occlusion Queries
Summary
8. Vertex Shaders
Vertex Shader Overview
Vertex Shader Built-In Variables
Precision Qualifiers
Number of Uniforms Limitations in a Vertex Shader
Vertex Shader Examples
Matrix Transformations
Lighting in a Vertex Shader
Generating Texture Coordinates
Vertex Skinning
Transform Feedback
Vertex Textures
OpenGL ES 1.1 Vertex Pipeline as an ES 3.0 Vertex Shader
Summary
9. Texturing
Texturing Basics
2D Textures
Cubemap Textures
3D Textures
2D Texture Arrays
Texture Objects and Loading Textures
Texture Filtering and Mipmapping
Automatic Mipmap Generation
Texture Coordinate Wrapping
Texture Swizzles
Texture Level of Detail
Depth Texture Compare (Percentage Closest Filtering)
Texture Formats
Using Textures in a Shader
Example of Using a Cubemap Texture
Loading 3D Textures and 2D Texture Arrays
Compressed Textures
Texture Subimage Specification
Copying Texture Data from the Color Buffer
Sampler Objects
Immutable Textures
Pixel Unpack Buffer Objects
Summary
10. Fragment Shaders
Fixed-Function Fragment Shaders
Fragment Shader Overview
Built-In Special Variables
Built-In Constants
Precision Qualifiers
Implementing Fixed-Function Techniques Using Shaders
Multitexturing
Fog
Alpha Test (Using Discard)
User Clip Planes
Summary
11. Fragment Operations
Buffers
Requesting Additional Buffers
Clearing Buffers
Using Masks to Control Writing to Framebuffers
Fragment Tests and Operations
Using the Scissor Test
Stencil Buffer Testing
Blending
Dithering
Multisampled Anti-Aliasing
Centroid Sampling
Reading and Writing Pixels to the Framebuffer
Pixel Pack Buffer Objects
Multiple Render Targets
Summary
12. Framebuffer Objects
Why Framebuffer Objects?
Framebuffer and Renderbuffer Objects
Choosing a Renderbuffer Versus a Texture as a Framebuffer Attachment
Framebuffer Objects Versus EGL Surfaces
Creating Framebuffer and Renderbuffer Objects
Using Renderbuffer Objects
Multisample Renderbuffers
Renderbuffer Formats
Using Framebuffer Objects
Attaching a Renderbuffer as a Framebuffer Attachment
Attaching a 2D Texture as a Framebuffer Attachment
Attaching an Image of a 3D Texture as a Framebuffer Attachment
Checking for Framebuffer Completeness
Framebuffer Blits
Framebuffer Invalidation
Deleting Framebuffer and Renderbuffer Objects
Deleting Renderbuffer Objects That Are Used as Framebuffer Attachments
Reading Pixels and Framebuffer Objects
Examples
Performance Tips and Tricks
Summary
13. Sync Objects and Fences
Flush and Finish
Why Use a Sync Object?
Creating and Deleting a Sync Object
Waiting for and Signaling a Sync Object
Example
Summary
14. Advanced Programming with OpenGL ES 3.0
Per-Fragment Lighting
Lighting with a Normal Map
Lighting Shaders
Lighting Equations
Environment Mapping
Particle System with Point Sprites
Particle System Setup
Particle System Vertex Shader
Particle System Fragment Shader
Particle System Using Transform Feedback
Particle System Rendering Algorithm
Particle Emission with Transform Feedback
Rendering the Particles
Image Postprocessing
Render-to-Texture Setup
Blur Fragment Shader
Projective Texturing
Projective Texturing Basics
Matrices for Projective Texturing
Projective Spotlight Shaders
Noise Using a 3D Texture
Generating Noise
Using Noise
Procedural Texturing
A Procedural Texture Example
Anti-Aliasing of Procedural Textures
Further Reading on Procedural Textures
Rendering Terrain with Vertex Texture Fetch
Generating a Square Terrain Grid
Computing Vertex Normal and Fetching Height Value in Vertex Shader
Further Reading on Large Terrain Rendering
Shadows Using a Depth Texture
Rendering from the Light Position Into a Depth Texture
Rendering from the Eye Position with the Depth Texture
Summary
15. State Queries
OpenGL ES 3.0 Implementation String Queries
Querying Implementation-Dependent Limits
Querying OpenGL ES State
Hints
Entity Name Queries
Nonprogrammable Operations Control and Queries
Shader and Program State Queries
Vertex Attribute Queries
Texture State Queries
Sampler Queries
Asynchronous Object Queries
Sync Object Queries
Vertex Buffer Queries
Renderbuffer and Framebuffer State Queries
Summary
16. OpenGL ES Platforms
Building for Microsoft Windows with Visual Studio
Building for Ubuntu Linux
Building for Android 4.3+ NDK (C++)
Prerequisites
Building the Example Code with Android NDK
Building for Android 4.3+ SDK (Java)
Building for iOS 7
Prerequisites
Building the Example Code with Xcode 5
Summary
A. GL_HALF_FLOAT
16-Bit Floating-Point Number
Converting a Float to a Half-Float
B. Built-In Functions
Angle and Trigonometry Functions
Exponential Functions
Common Functions
Floating-Point Pack and Unpack Functions
Geometric Functions
Matrix Functions
Vector Relational Functions
Texture Lookup Functions
Fragment Processing Functions
C. ES Framework API
Framework Core Functions
Transformation Functions
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Z