About OpenGL ES
The Open Graphics Library (OpenGL) is used for visualizing 2D and 3D data. It is a multipurpose open-standard graphics library that supports applications for 2D and 3D digital content creation, mechanical and architectural design, virtual prototyping, flight simulation, video games, and more. OpenGL allows application developers to configure a 3D graphics pipeline and submit data to it. Vertices are transformed and lit, assembled into primitives, and rasterized to create a 2D image. OpenGL is designed to translate function calls into graphics commands that can be sent to underlying graphics hardware. Because this underlying hardware is dedicated to processing graphics commands, OpenGL drawing is typically very fast.
OpenGL for Embedded Systems (OpenGL ES) is a simplified version of OpenGL that eliminates redundant functionality to provide a library that is both easier to learn and easier to implement in mobile graphics hardware.
At a Glance
Apple provides implementations of both OpenGL ES 1.1 and OpenGL ES 2.0:
OpenGL ES 1.1 implements a well-defined fixed-function pipeline. The fixed-function pipeline implements a traditional lighting and shading model that allows each stage of the pipeline to be configured to perform specific tasks, or disabled when its functionality is not required.
OpenGL ES 2.0 shares many functions in common with OpenGL ES 1.1, but removes all functions that target the fixed-function vertex and fragment pipeline stages. Instead, it introduces new functions that provide access to a general-purpose shader-based pipeline. Shaders allow you to author custom vertex and fragment functions that are executed directly on the graphics hardware. With shaders, your application can more precisely and more clearly customize the inputs to the pipeline and the computations that are performed on each vertex and fragment.
OpenGL ES is a C-based, Platform-Neutral API
Because OpenGL ES is a C-based API, it is extremely portable and widely supported. As a C API, it integrates seamlessly with Objective-C based Cocoa Touch applications. The OpenGL ES specification does not define a windowing layer; instead, the hosting operating system must provide functions to create an OpenGL ES rendering context, which accepts commands, and a framebuffer, where the results of any drawing commands are written to.
OpenGL ES is Integrated into Core Animation
Core Animation is fundamental to iOS graphics, and that includes OpenGL ES content that your application delivers to the screen. When you develop an OpenGL ES application, your OpenGL ES content is rendered to a special Core Animation layer, known as a
CAEAGLLayer object. The images you render using OpenGL ES are stored in the
CAEAGLLayer. Core Animation composites these images with content in other layers and delivers the final image to the screen.
Framebuffer Objects are Always the Rendering Destination
The OpenGL ES specification assumes there are two kinds of framebuffers: system-provided framebuffers and framebuffer objects. A system framebuffer is allocated using an API provided by the host operating system, and connects to the screen or windowing environment. Framebuffer objects target offscreen rendering without a direct connection to the screen or windowing environment. iOS only uses framebuffer objects; rather than create a separate system framebuffer, iOS extends the OpenGL ES API to allow a framebuffer object to be allocated so that its contents are shared with Core Animation.
Functionality May Vary on Different Devices
iOS devices support a variety of graphics processors with varying capabilities. Some devices support both OpenGL ES 1.1 and OpenGL ES 2.0; older devices only support OpenGL ES 1.1. Even devices that support the same version of OpenGL ES may have different capabilities depending on the version of iOS and the underlying graphics hardware. Apple offers many OpenGL ES extensions to provide new capabilities to your applications. For details, see OpenGL ES Hardware Platform Guide for iOS.
To allow your application to run on as many devices as possible and to ensure compatibility with future devices and iOS versions, your application must always test the capabilities of the underlying OpenGL ES implementation at run time, disabling any features that do not have the required support from iOS.
Applications Require Additional Performance Tuning
Graphics processors are parallelized devices optimized for graphics operations. To get great performance in your application, you must carefully design your application to feed data and commands to OpenGL ES so that the graphics hardware runs in parallel with your application. A poorly tuned application forces either the CPU or the GPU to wait for the other to finish processing commands.
You should design your application to efficiently use the OpenGL ES API. Once you have finished building your application, use Instruments to fine tune your application’s performance. If your application is bottlenecked inside OpenGL ES, use the information provided in this guide to optimize your application’s performance.
Xcode 4 provides new tools to help you improve the performance of your OpenGL ES applications.
OpenGL ES May Not Be Used in Background Applications
Applications that are running in the background may not call OpenGL ES functions. If your application accesses the graphics processor while it is in the background, it is automatically terminated by iOS. To avoid this, your application should flush any pending commands previously submitted to OpenGL ES prior to being moved into the background and avoid calling OpenGL ES until it is moved back to the foreground.
OpenGL ES Places Additional Restrictions on Multithreaded Applications
Designing applications to take advantage of concurrency can be useful to help improve your application’s performance. If you intend to add concurrency to an OpenGL ES application, you must ensure that the application does not access the same context from two different threads at the same time.
How to Use This Document
If you are new to OpenGL ES or iOS development, begin by reading “OpenGL ES on iOS,” which provides an overview of the architecture of OpenGL ES and how it integrates into iOS. Read the remaining chapters in order.
Experienced iOS developers should focus on reading “Drawing With OpenGL ES” to learn new details about how to integrate OpenGL ES into your application as well as how to correctly implement your rendering loop. Then, read “OpenGL ES Application Design Guidelines” to dig deeper into how to design efficient OpenGL ES applications.
Before attempting to create an OpenGL ES application, you should already be familiar with views, and how views interact with Core Animation. See View Programming Guide for iOS.
Although this document introduces important OpenGL ES concepts, it is not a tutorial or a reference for the OpenGL ES API. To learn more about creating OpenGL ES applications, consult the references below.
OpenGL ES is an open standard defined by the Khronos Group. For more information about OpenGL ES 1.1 and 2.0, please consult their web page at http://www.khronos.org/opengles/.
OpenGL® ES 2.0 Programming Guide, published by Addison-Wesley, provides a comprehensive introduction to OpenGL ES concepts.
OpenGL® Shading Language, Third Edition, also published by Addison-Wesley, provides many shading algorithms useable in your OpenGL ES application. You may need to modify some of these algorithms to run efficiently on mobile graphics processors.
OpenGL ES API Registry is the official repository for the OpenGL ES 1.1 and OpenGL ES 2.0 specifications, the OpenGL ES shading language specification, and documentation for OpenGL ES extensions.
OpenGL ES 1.1 Reference Pages provides a complete reference to the OpenGL ES 1.1 specification, indexed alphabetically.
OpenGL ES 2.0 Reference Pages provides a complete reference to the OpenGL ES 2.0 specification, indexed alphabetically.
OpenGL ES Framework Reference describes the platform-specific functions and classes provided by Apple to integrate OpenGL ES into iOS.
OpenGL ES Hardware Platform Guide for iOS provides more detailed information on the available hardware and software available to your application.
© 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-04-23)