I’ve always been interested in OpenGL and I finally gave it a try.

OpenGL stands for “Open Graphics Library” it is basically a specification for a bunch of methods that GPU Providers implement, so it is tied to your graphics card. Because of that, the hardware and the OpenGL version you target is important.

Prior to this I’ve had very basic experience with libGDX, a Java game engine which I tried to use it on Android.

OpenGL versions

The latest OpenGL versions of today is something around 4.6, you need to mind your version when choosing what you are targetting.

macOS

Unfortunately Apple has deprecated OpenGL and is encouraging people to use their Metal interface for graphics. OpenGL still works but is frozen at version 4.2 or something and probably won’t see any updates. It is also unknown whether it might get removed in the future.

Linux

OpenGL probably works best on Linux since it’s their primary graphics interface, while Apple is on their Metal and Windows is on Direct3D, Linux just uses OpenGL primarily.

Cross-platform games using a cross-platform game engine would ideally create an OpenGL backend for Linux, Metal backend for macOS and a Direct3D backend for Windows.

Although if you were limited to one backend, OpenGL is still the most cross-platform of them, even though macOS deprecated it you don’t need to worry unless you care about the latest OpenGL versions, which you probably don’t if you are trying to support a variety of hardware.

Android

Android also supports OpenGL as early as Android 2 or so, so we have decent support available. The flavor of OpenGL on Android is called “OpenGL ES” the ES standing for Embedded Systems. It’s OpenGL optimized for embedded devices like Android.

On Android you would normally target OpenGL ES 2.0 for best support across devices. Though Google shows that about 76% of devices support OpenGL ES 3.0 too.

The important thing to note is that OpenGL ES 1.0 is different and not so compatible with other versions while OpenGL ES 3.0 is fully compatible with OpenGL ES 2.0 so it’s possible to target OpenGL ES 2.0 and use OpenGL ES 3.0 features if the hardware supports it.

I’m primarily interested in Android so this is what I mainly focus on.

Which version to learn and use?

All this versions create a bit of confusion on where to start. There are ancient tutorials using OpenGL 1.0 and other tutorials that brag about their tutorial being “modern” with latest OpenGL 4.0

The answer to this mainly depends on what your goals are and what hardware you are targetting.

OpenGL 1 used to have an easy API therefore some tutorials suggest starting with OpenGL 1 since it has a lot of convenience methods. In return it’s slower and not as flexible in some cases.

OpenGL 2+ changed the API significantly by introducing shaders and more low level functions.

Personally I think I’ll start with OpenGL 2, the newer versions are compatible with OpenGL 2 and just add more functions, and I don’t want to make transitioning difficult starting from OpenGL 1.

If you are planning to create some high-end game targetting newest hardware then by all means go for the newer versions, but that’s unlikely if you are reading this and want to start somewhere. That said starting from OpenGL 3 is also not a bad idea, since 76% of Android devices also support it, it’s not a bad idea at all.

Windowing System

Another thing you must know about OpenGL is that it just draws graphics, that’s it, it can’t create an application window, handle keyboard and mouse input. That’s up to you to find a solution for it and wire it up with your graphics.

On Android there is already builtin support in the SDK through the Java class GLSurfaceView it’s quite easy to setup and you can start drawing graphics instantly, it can also handle keyboard and touch input.

On Desktop you could either handle windowing manually, using the platform APIs like Win32 API for Windows, X11 for Linux, Cocoa for macOS but that’s not practical for us to begin with, because of this there exists many libraries that handle window initialization and input handling and allow us to just focus on the graphics.

A few of this are glfw and freeglut various more exist. A few more exist that are slightly higher level and provide more functionality these include SDL, SFML and more.

It is up to you what you prefer to use, each of them have their own good stuff.

Game Engines

Even higher-level game engines exist that leverages OpenGL behind the scene, with these you have less to worry about OpenGL because they will abstract all the graphics with say a Sprite class and vice versa.

One Game Engine I used is libGDX for java, although I didn’t do much with it yet I got a grasp of its basics.

I’m this guy who loves to jump into the difficult stuff rightaway and then right after, sink.

I could barely use libGDX properly and I felt like “Oh OpenGL? What if I learn that, create my own 3D Game Engine and create amazing games.” And here I am struggling with OpenGL tutorials, and Math.

But reading a bit about OpenGL directly made me appreciate libGDX a lot more and already feel like I’m a better libGDX user.

Conclusion

This was my very basic introduction to OpenGL and what I learned so far, the journey only started and I look forward to see what I can do in the future. For now I’ll continue learning bit by bit and maybe update this article over time.

One of my goals still remain to create a game engine from scratch by applying OpenGL so hopefully one day I’ll get there, see you until then.