Today’s web and mobile users expect a seamless experience that combines rich content and excellent responsiveness — streaming video, 3D graphics, large-scale imagery, smooth and snappy UI animations, and so on. All of this means doing a lot of demanding graphics processing. To deliver on these expectations we have had to step into the world of hardware-accelerated graphics with the help of OpenGL. Here are some of the ways OpenGL has proven to be so beneficial:
Raw speed is the main advantage for using OpenGL. In fact, the rest of this list is only possible because of this incredible speed. The engine powering this speed is the Graphics Processing Unit, or GPU. When a normal processor draws an image, it has to step through each pixel one by one. The screen you are looking at right now probably has millions of pixels, so this is obviously slow. A GPU, however, uses parallel processing and can grab big bunches of pixels and do them all at once. In fact, modern GPUs have fill rates measured in the billions of pixels per second. This means you can create very complex visuals that would simply be impossible otherwise.
There are other very good alternatives to OpenGL like Microsoft’s DirectX for example, or Apple’s Metal. But these are platform-specific (DirectX will only work with Windows) whereas OpenGL is designed to be platform-agnostic. If you write an OpenGL implementation for the iPhone, it can be ported to Android with almost no changes and you’d get identical results. When you’re developing an app for multiple platforms, this is can save a lot of development effort.
Sometimes a web site or web app makes more business sense than a mobile app (more about that here), basically ruling out high performance graphics. But recently we’ve seen the widespread adoption of the WebGL standard. This is a special flavor of OpenGL designed to run in web browsers using HTML5. So now we can add hardware-accelerated graphics to web sites too, further improving OpenGL’s platform-independence. A WebGL app will run identically whether it’s in Chrome on your laptop, Mobile Safari on your iPhone, or IE11 on your Surface Tablet. All from the exact same code.
Shrinking Barrier to Entry
OpenGL can be difficult to get into because of its complexity. But everyday, new frameworks are being developed that make it increasingly easier, particularly with WebGL. Frameworks like ThreeJS and Babylon make getting started in WebGL a breeze. And many platforms now incorporate OpenGL into everyday tasks so you might be using it already and not even realize it. iOS Core Graphics, Android’s Surface, and HTML5’s Canvas are all backed by OpenGL to allow even mundane tasks to benefit from hardware acceleration — text rendering or page scrolling for example. All of these tools allow developers to get to the business of making awesome visuals quickly without having to understand the very technical nuts and bolts. This means the reasons for not using OpenGL are rapidly disappearing.
Nothing adds visual kick quite like advanced 3D graphics, and that is one of the best and most common uses for OpenGL. By adding a third dimension you can create a sense of physicality and tangibility in your imagery that would otherwise be impossible to achieve. This also allows you to convey complex ideas and visualize big data in intuitive and easy-to-understand ways. And the speed of the GPU means you can change and customize visuals on the fly based on user input. But OpenGL isn’t limited to 3D graphics. It is commonly used to make UI animations more responsive or to handle embedded video or to draw vector graphics – really any visual element you put on the screen is fair game for OpenGL.
OpenGL is becoming increasingly ubiquitous and understanding how to leverage its incredible power is a must for developers. For more information about OpenGL and WebGL and how to get started, visit Khronos’ website at https://www.opengl.org/.