OpenGL is a graphics library that has provided a foundation for many other high-level graphics libraries built on top of it. Because it is so versitle and low-level, it has been proven to stand the test of time, and has evolved to handle the changing demands that library authors have been placed on it. As demands have changed, new functions are added, and one trend between all versions of OpenGL is that more specific functions are being replaced by more general functions. For example, the functions glColorPointer
, glNormalPointer
, and glTexCoordPointer
have been augmented with glVertexAttribPointer
, which can be used to replace all of the previous functions. This has led to a completely different view of OpenGL that has led to the development of smaller profile of OpenGL functions called the Embedded Specification, or OpenGL-ES for short. One side effect of this is that the more abstract functions are increasingly similar to an object-oriented library, which means there are fewer and fewer functions that do not fit into an object model of OpenGL. If we partition the functions found in OpenGL-ES 2.0 into an object-oriented hierarchy, then we arrive at the following classes:
- Blend
- Buffer -- pixel buffers, vertex buffers, and index buffers
- Capability -- abstract class with glEnable and glDisable
- Clear -- clearing the background to a solid color
- Color
- CullFace -- consists of glCullFace and glFrontFace
- Depth
- FrameBuffer
- Get -- reading global state with functions like glGetString etc.
- Mipmap -- utilities for the Texture class
- Program
- RenderBuffer
- Shader -- vertex and fragment shaders
- Stencil
- Texture
- Uniform -- uniform variables
- VertexAttrib -- vertex attributes
after removing these functions from the OpenGL-ES 2.0 API, we are left with the miscellaneous functions:
- glDrawArrays(mode, first, count)
- glDrawElements(mode, count, type, indices)
- glFinish()
- glFlush()
- glLineWidth(width)
- glPolygonOffset(factor, units)
- glSampleCoverage(value, invert)
- glPixelStorei(name, param)
- glReadPixels(x, y, width, height, format, type, pixels)
- glScissor(x, y, width, height)
- glViewport(x, y, width, height)
This says a lot about OpenGL-ES, especially the fact that glDrawPixels
has been removed. This means the only way to copy pixels into an OpenGL-ES context is to apply a texture with the pixel data to a rectangle. However, OpenGL-ES forbids GL_QUADS
, so you have to use GL_TRIANGLE_FAN
to accomplish the same result. glReadPixels
, glScissor
, and glViewport
can be related in that they all accept a rectangle as an argument.
Although OpenGL-ES allows one to do everything that can be done in OpenGL 2.0, there is more of a suggestion to use more general interfaces, like shaders and buffer objects, since all of the fixed functionality has been removed. This means that it is possible to reimplement all of OpenGL in OpenGL-ES. However, since ES is still rather new, there have not been any such implementations of fixed functionality in terms of shaders or the like. There are some tutorials that show how to duplicate such simple functionality as colors in terms of shaders, but a complete reimplementation is still nowhere to be found.
No comments:
Post a Comment