Chapter 4 - Programming models & APIs: Part 1

 

With the advent of programmable graphics hardware, several solutions have been proposed to ease the process of accessing programmable units like fragment and vertex shaders unit bypassing the assembly language constraint. Vendor-dependent and independent APIs are available each featuring a plethora of capabilities ranging from the cross-platform OpenGL Shading Language to the sofistication of DirectX. The new era is also seeing GPUs becoming more and more sophisticated to the extent of assuming a unique identity distinct from the purpose they were originally designed for. General-purpose computing on graphics processing units (GPGPU) is pushing what once was a dedicated graphics rendering device to perform tasks traditionally handled by CPUs. CUDA, StreamSDK, RapidMind and OpenCL represent today the latest programming interface for parallel computing hardware like GPGPUs. Still far from determining the "standard", each solution brings its own perspective into the market, opening up general-purpose computing from servers to workstations to handheld devices, to the world of GPU-accelerated software.

4.1 Graphics APIs

OpenGL and DirectX are representatives of established API for both graphics and graphics hardware programming. Diverse by design, OpenGL is an open standard API compatible with most modern operating systems, DirectX is a proprietary API designed by Microsoft Corporation and officially implemented only for Microsoft family operating systems. Both API provide a set of functions for traditional rendering of 2D and 3D graphics and graphics hardware acceleration. It is interesting to highlight the design choices behind the development of these two tools and how they respectively relate and respond to the rapid advance of graphics technology and software solutions.

4.1.1 OpenGL

OpenGL stands for OpenGraphics library and was first developed by Silicon Graphics Inc. (SGI) in 1992 as an alternative to Iris GL the proprietary graphics API of Silicon Graphics workstations. Mark Seagal and Kurt Akeley authored the first library release named OpenGL 1.0. With respect to its Iris GL ancestor OpenGL featured a formal specification which represented the first attempt at establishing a formal definition of a graphics API. Conceived to be cross-platform the OpenGL project provided third party implementation and support from its start plus a complete suite of conformance tests to allow third party library extension development. In 1992 the OpenGL Architecture Review Board (ARB) was established as an independent consortium to oversee the future of OpenGL. Main duties of the OpenGL ARB are the certification of extensions, additions and major modification to the library core. As of today OpenGL has moved to become part of the Khronos Group [1].

The evolution of the OpenGL library has seen the incremental addition of new features to the core API. Extensions to the library have been gradually incorporated and as of this date OpenGL 2.1 appears to be the latest release with significant additions like the OpenGL Shading Language (GLSL) and the OpenGL for Embedded Systems (OpenGL ES).

4.1.1.1 GLSL

The OpenGL Shading Language (GLSL) [2,3] is a high level shading language largely based on the ANSI C programming language. Being part of the OpenGL library GLSL-developed shaders are not standalone applications but require an application that utilizes the OpenGL API. A shader is a computer program fragment that calculates rendering effects on graphics hardware. GLSL enables the programmer to implement shaders for the programmable hardware contained in the OpenGL processing pipeline. At runtime GLSL programs have automatic access to part of the OpenGL state which can be affected by a shader. This allows the application to use existing OpenGL state commands for state management and have the current values of such state (like colour or light intensity) automatically available for use in a shader. GLSL supports the implementation of both vertex and fragment shaders.

4.1.1.2 OpenGL ES

OpenGL for Embedded Systems (OpenGL ES) is a low level API for 2D and 3D graphics acceleration on embedded and mobile devices. Currently two releases are available: OpenGL ES 1.X defined relatively to OpenGL 1.5 and for fixed function hardware only, OpenGL ES 2.X defined relatively to OpenGL 2.0 and for programmable hardware. OpenGL ES can be seen as a subset of the corresponding OpenGL since it does not support the entire OpenGL functionalities. The complexity of the processing pipeline is highly simplified in both releases. OpenGL ES 2.0 however presents the most significant differences: fixed function transformation, lighting and fragment rendering pipelines are completely removed and replaced by programmable ones (i.e. shaders), commands can no longer be accumulated in display lists for later processing and the first stage of the processing pipeline which evaluates geometric approximation for curves and surfaces is eliminated. As a result OpenGL ES 2.X is not backward compatible with OpenGL ES 1.X. For a more detailed review of the main differences between OpenGL ES and OpenGL 2.X refer to [4].


  1. Khronos group - opengl, jan 2009. www.khronos.org/opengl/.
  2. Khronos OpenGL Working Group. The OpenGL Shading Language (GLSL) Quick Reference Guide. Version 1.10.
  3. Khronos OpenGL Working Group. The OpenGL Shading Language, Sept. 2006. Version 1.20.
  4. Khronos OpenGL Working Group. OpenGL ES 2.0.23 Difference Specification, Sept. 2006. www.khronos.org/opengles/2_X/