My third week of UROP: OpenGL ES

For my third week of UROP, having completed the UI generation, I started looking into OpenGL ES (OpenGL for Embedded Systems). I wanted to be able to generate graphs of sine waves through OpenGL ES on both iOS and Android. This would give me the power to create animated graphs. To start I will just be drawing static sine waves that can be zoomed into/out of. However, eventually I hope to create more interesting scenes that show the input wave vs output wave being generated together.

About OpenGL ES

OpenGL is the industry standard high performace graphics library. OpenGL ES is the version for embedded systems, and, it is this is the version that runs on mobile devices. OpenGL ES is a cut down version of OpenGL, tuned for performace and speed in low power environments such as embedded microprocessors. There are different versions of OpenGL ES, at current there are: 1.1, 2.0 and 3.0. Different versions of OpenGL ES do not maintain backward compatibility with the older versions, so although some code does not change, other major features may variy significantly between versions.

I am not going to go into detail here about the difference between the versions, or about how OpenGL ES works / how to program it. I am going to write a blog post dedicated to OpenGL ES 2.0 and implementing it for iOS for beginners that explains all of that, so if you're interested keep an eye out for it, or check back here and I will link to it when I've written it.

I have decided to use OpenGL ES 2.0 for my development. It has been available on both mobile platforms since 2010 (iOS 5 and Android 2.2), so it makes sence to use choose this version over OpenGL ES 1.1. You might think, why not OpenGL ES 3.0? The answer is that, although the latest, is yet to be widely supported and therefore would not be the best choice to maximise device compatability.

Learning OpenGL ES 2.0

I made the choice to start learning OpenGL ES 2.0 development on the iOS platform as I have more experince developing for it. I started looking around for tutorials for OpenGL ES 2.0 and quickly found that most of them were written in 2010 (no surprise there I guess). However, this meant that they were out of date when armed with the latest features in the iOS Software Development Kit (SDK). Also, the majority of tutorials and books I read through used C++ for the majority of the implementation, which is something that I wanted to avoid. This meant that as well as having to modernise what I was reading, I also had to convert the language from C++ to Objective-C.

It took me the majority of the week to get my head around things. But once they clicked, they clicked and I'm happy with how things have turned out. I fully implemented sine graph drawing in OpenGL ES 2.0 for iOS.

Converting to Android

So after I wrote the code to draw sine graphs on iOS, I assumed as most of the functions were from the OpenGL ES 2.0 library that porting it to Android would be easy and take just a few minutes. I was very wrong. The implementation Android was very different, this is mainly due to quirks of Java, but also is somewhat related to how Android implements the OpenGL ES libraries.

It took me all day today to finish porting my code and at the time of writing (23:30 BST) I've still yet to actually run the code to test if it works as expected, that can wait until tomorrow, or Monday at the latest.

So what's next?

So, next week, I shall be working on finish up the graphing on Android and then I will start to finalise the UI, adding labels, the description and working out how users will transition between models. By the end of the week I hope to have all major features implemented such that the last two weeks are spent on finishing and polishing the application so that it's ready to be used by students.

Comments