OpenGL is an open standard maintained by the Khronos Group, not controlled by any single corporation. It is used to render graphics in many desktop computers, mobile devices and video game consoles, and many other types of embedded devices ranging from medical equipment to aerospace instrumentation.
It's often compared to DirectX, which is a proprietary API by Microsoft. It serves the same purpose as OpenGL but for Windows platforms only. DirectX is generally more prevalent on PC gaming systems than OpenGL because originally, DirectX was exclusive to Windows operating systems, while many other operating systems have access to OpenGL drivers.
What is OpenGL architecture?
The architecture of OpenGL consists of a generic function library, which handles graphics rendering in general, and an API that defines the platform specifics. The library allows programmers to use it with any supported operating system or windowing system.
The API makes it easier to use OpenGL functions by removing cross-platform issues such as different graphics hardware capabilities, different windowing systems and operating system graphics device drivers. In addition, the architecture of OpenGL takes advantage of a layered design that makes it easier to extend it in the future without breaking support for older hardware devices.
OpenGL interface functions with the ‘client-side’ API library in basic implementations, which does not include hardware-specific code. The library is composed of the necessary state-setting steps, utility routines for managing resources and access to other functions in the system. In addition, it provides a software abstraction of graphics devices by rendering them onto a local area 2D memory bitmap.
Hardware that supports it, or using vendor-specific OpenGL extensions, OpenGL functions use platform-specific graphics APIs that allow the programmer to access the graphics hardware's capabilities.
Even on hardware that supports it, many functions are still not implemented by all of the available devices. In these cases, the generic implementation of an OpenGL function is used. For example, in some cases, low-level 3D scenes need to be rendered from more than one primitive type (triangles, lines, points). OpenGL lets the user code supply a custom callback function which the system then calls to determine how each primitive is drawn.
How is OpenGL's API organized?
The organization of OpenGL's API is broken up into distinct modules defined by separate headers. All header files containing references to externally accessible functions are collected in a top-level directory gl. The naming convention for functions is the name of the header file minus the extension, so for example, ‘gl.h’ contains all of OpenGL's core API. This includes definitions for each symbol and type used in the API header files contained in this directory.
Each OpenGL extension (each distinct feature that you can add to OpenGL) defines its own set of functions grouped together into an extension library. Core extensions are part of the official OpenGL specification, and this list is frequently updated with the latest industry standards.
There are many other vendor-specific or open-source extensions that you can use to expand the functionality of OpenGL, such as the ‘GL_EXT_debug_marker’ extension provided by the Mesa Graphics Library and used by a number of Linux distributions.
What is OpenGL not good at?
Using the OpenGL API is slow compared to lower-level APIs, making it unfeasible for games requiring real-time performance. However, you can use OpenGL in combination with lower-level APIs to improve the speed of certain rendering tasks.
OpenGL also has a number of dangerous features for developers without the right level of experience, creating easy ways to get into bugs, such as race conditions and inconsistent rendering between window-system specific back-ends.
What is the OpenGL Rendering Pipeline?
The OpenGL rendering pipeline works on blocks of data called "primitives". Primitives are drawn as meshes composed of one or more vertices, with each vertex containing its own position, colour and texture coordinate data. The core of the OpenGL rendering pipeline is the vertex processing stage. It is here that vertex data specified by the application is transformed and projected onto the 2D plane of the window.
The next steps in the pipeline are performed on a per-fragment basis, rather than per-vertex or per-primitive. These steps involve up to four more calculations: interpolation, clipping, viewport transformation, and finally, the rasterization stage.
The final step in the rendering pipeline, the fragment processing stage, is where most of the graphics state is held so that subsequent steps in the rendering pipeline can use this information. The data for each fragment generated during rasterization is read back from memory and passed to this function.
It's accessible and comprehensive
OpenGL is undoubtedly comprehensive. It provides access to virtually any graphics-related feature imaginable (including things like rendering fonts), and the number of extensions continues to grow. It provides a standard interface for all programs written in OpenGL, which makes writing portable software easy.
Over time OpenGL has grown beyond its low-level roots driven by efficiency and has transformed into a real-time high-level rendering API.