In the following article we would like to introduce you to the basic concepts of OpenGL (important for 3D configurators). The answers to the following questions will be the focus of this article:
What is OpenGL?
OpenGL, short for OpenGraphics Library, is a cross- language and -platform API for displaying 2D and 3D computer graphics. Here we will specifically discuss the ES (embedded system) version used on mobile devices (iOS and Android). OpenGL`s main competitor is D3D (or Direct3D), a Windows technology that is part of the well-known DirectX API.
Simply put, OpenGL is a way to program the GPU and it is the heart of almost everything we see on a computer / smartphone / tablet today. EvenUIKit relies on OpenGL. OpenGL is the technology behind graphic rendering.
In Apple`s technology stack there are different frameworks to do different things. You should use CoreGraphics and CoreImage to edit images and filters, CoreAnimation to animate views, SceneKit to manage 3D objects. So why and when should you use OpenGL? In short, if you want to access the powerful features of your device`s graphics card (GPU). By the way, OpenGL is currently the only way to display a 3D object in a native iOS application.
By the way, if someone has told you that OpenGL is the most suitable and powerful tool for creating video games, that`s only part of the truth. Certainly OpenGL supports all modern games (except those running on MSFT D3D), but hardly any of them (except for large studios) are rewritten from scratch. And if you`re interested in such topics, you might want to try other frameworks (whether 2D or 3D) that have a higher level of abstraction.
OpenGL ES.
So, let`s focus on OpenGL ES. Most of the things we`ll cover will also apply to OpenGL, some of which are specific to the embedded version. From now on, when we talk about OpenGL, we mean the ES version. Let us briefly discuss some important points that are at the heart of OpenGL:
OpenGL ES v. 1 vs. 2.
Starting with iOS 3.0, Apple supports OpenGL ES 2 and has strongly encouraged developers to upgrade to the lastest version of the graphics library. The main difference between v.1 and v.2 is the so-called programmable pipeline. Basically, OpenGL ES 2 provides and requires the definition of own shaders (specific programs running on the GPU and not on the CPU).
While in v.1 you can pass anything but raw data to the GPU, in v.2 you have to define your own shaders. This means: more performance, more work for the developer. OpenGL ES v.2 indeed requires you to write:
Since this was one of the main reasons why developers didn`t move towards v.2, Apple introduced a new framework with iOS 5, GLKit.
So much for theory. If, for example, you would like to learn WebGL, we recommend that you work through our WebGL tutorial series. At this point, it`s enough to say that GLKit offers some ways to take care of some of the harder bits and repetitive OpenGL things. Apart from some useful mathematical tools for dealing with matrices, quaternions, affine and homogeneous trasnformations, and similar other frightening elements. GLKit has introduced GLKBaseEffect, a class that eliminates all the complexity of shaders. We will discuss this in more detail in a future article.