OpenGL ES(OpenGL for Embedded systems): This is a version of OpenGL designed for mobile devices.
OpenGL ES on iPhone: OpenGL ES allows your application to configure a traditional 3D graphics pipeline and submit vertex data to OpenGL, where they are transformed and lit, assembled into primitives, and rasterized to create a 2D image.There are 2 versions of OpenGLES are available.
OpenGL ES 1.1: This implements the standard graphics pipeline with a well-defined fixed-function pipeline.The fixed function pipeline implements a traditional lighting and rasterization model that allows various parts of the pipeline to be enabled and configured to perform specific tasks, or disabled to improve performance.
OpenGL ES 2.0: It is same as OpenGL ES 1.1,but removes all functions that act on a fixed function pipeline, replacing it with a general purpose shader-based pipeline.
OpenGL ES provides a procedural API for substituting geometry to a hardware accelerated rendering pipeline, OpenGL ES commands are submitted to a rendering context , where they are consumed to generate images that can be displayed to the user.
Any OpenGL ES implementation provides a platform-specific library that includes functions to create and manipulate rendering context.The rendering context maintains a copy of all OpenG ES state variables and accepts and executes all OpenGL ES commands.In iPhone OS, EAGL is the library that provides this functionality.An EAGLContext is rendering context, executing OpenGL ES commands and interacting with Core Animation to present the final images to the user.
iPhone OS Classes:
All implementations of OpenGL ES require platform specific code to create a rendering context and use it to draw to the screen.iPhone OS does this through EAGL, an Objective C interface.
EAGLContext: The EAGLContext class defines the rendering context that is target of all OpenGLES commands.
Steps:
- Create and initialize an EAGLContext object and make it the current target of commands.
- Store all the commands issued by OpenGL ES in queue that is maintained by the context.
- Execute all the commands to render the final image.
By sharing textures, shaders and other objects , your object makes better use of available resources.
EAGLDrawable: iPhone OS objects that implement the EAGLDrawable protocol can be used as a rendering surface and displayed to the screen by an EAGLContext object.And you can configure the drawable surface with Drawable Properties(A dictionary of values that specify the desired characteristics of the drawable surface).
OpenGL ES Objects:
OpenGL ES offers a number of objects that can be created and configured to help creating you screens.
- Texture: A texture is a image that can be sampled by graphics pipeline. This is typically used to map a color image onto your geometry.
- Buffer: A buffer is a set of memory owned by OpenGL ES that your application can read and write data into(normally to hold vertex data). Using buffers to manage your vertex data can significantly boost the performance of your application because the buffer is owned by the OpenGL ES implementation, it can optimize the placement and format of the data in this buffer in order to more efficiently process vertices,particularly when data does not change from frame to frame.
- Shaders: An OpenGL ES 2.0 application creates a shader, compiles and links code into it, and assigns it to process vertex and fragment data.
- Render Buffer: A render buffer is a simple 2D graphics image in a specified format.This format may be defined as color data, but it could also be depth or stencil information.Render buffers are not usually used alone, but are instead collected and used as part of a frame buffer.
- Frame buffer: Frame buffers are the ultimate destination of the graphics pipeline.A frame buffer object is really just a container that attaches texture and render buffer to itself to create a complete destination for rendering.
Standard model that all OpenGL ES objects should share:
- Generate an object identifier: To generate/create object, you should generate an identifier.An identifier is analogous to a pointer.Whenever your application wants to operate on an object,you use this identifier to specify which object to work on. Creating an object identifier does not actually allocate an object. It simply allocate a reference to it.
- Bind your object to OpenGL ES context: Each object type in OpenGL ES has a method to bind an object to the context. You can only work on one object of each type at a time, and you select that object by binding to it. The first time you bind to an object identifier, OpenGL ES allocates memory and initializes that object.
- Modify the state of your object: Commands implicitly operate on the currently bound object.After binding the object, you application makes one or more OpenGL ES calls to configure it.Ex:After binding the texture, your application actually makes an additional call to actually load the texture image.
- Use your object for rendering: once you have created and configured, you can start drawing your geometry.
- Delete your object.
Actions that most of commands in OpenGL ES do:
- Reading the current state of an OpenGL ES context.This is most typically used to determine the capabilities of an OpenGL ES implementation.
- Changing state variables in an OpenGL ES context.This is typically used to configure the pipeline for some future operations,
- Creating, modifying or destroying OpenGL ES objects.
- Submitting geometry to be rendered.Vertex data is submitted to the pipeline, processed, assembled and then rasterized to a frame buffer.
Creating an EAGLContext:
Before your application can execute any OpenGL ES commands, it must first create and initialize an EAGLContext and make it the current context.
EAGLContext* myContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
[EAGLContext setCurrentContext:myContext];Creating FrameBuffers:
FrameBuffer objects are the target of all rendering commands.Traditionally in OpenGL ES, frame buffers are created using a platform-defined interface.Each platform would provide its own functions to create a frame buffer that can be drawn to the screen.
FrameBuffer Object provides storage for color, depth and/or stencil data by allocating images to the frame buffer.
Although an EAGL context receives commands, it is not the ultimate target of those commands. Your application provides a destination to render the pixels into.In iPhone Os all images are rendered to frame buffer objects.frame buffer object allows your application to precisely control the creation of color, depth and stencil targets.
