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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.26.138