Sunday, July 1, 2018

Drawing a triangle in an ANDROID App using OpenGL ES

Android apps are easily created using the android studio. Here the foremost priority for me was getting to create an OpenGL ES environment and draw a shape such as a triangle. I referred to the developer.android.com site where most of the explanation is voluminous and detailed to follow. It took me quite a while to fully understand.

I had to download an android studio which took a lot of time and finally after a few days I was good to go. 
I made my mobile work in developer mode and made several projects just to understand what developing for android feels like. 
The First app
The first app I made was an empty project. It involved just giving a name to the project and letting all the default settings as it is. I had seen one of my students fiddle with an app where he downloaded the app in his mobile and run it. I just did the same with this empty project and my mobile.
The Second app
A hello world app followed next. It just displayed a hello world message on the screen which I learnt to change.
The Third app
 This one read a text message and upon clicking Ok button sent the message to the next screen that displayed the message.

While all this was practice I jumped into making android apps which were more complex with the one where the app displays a triangle using OpenGL ES environment. I tried displaying a triangle using OpenGL.

I launched the app in the emulator. It started with the following screen.


There were several problems I encountered esp with OpenGL ES environment. It was frustrating to expect a triangle on the screen and just getting a black background. I knew I needed to persevere so after a few days I found time to set the kinks in order and finally was able to draw a triangle in OpenGL ES on the emulator.

I am well versed with OpenGL so immediately wanted to start off with drawing a Sierpinski gasket. I was very very tired that night. First up next morning I might not even have brushed. I was glued to the computer for nearly two hours. It was frustrating again.
I will list out exactly what went wrong.--- Will update Soon.
Update1:
Here is the latest app which goes further ahead and divides the triangle into sierpinski gasket:
https://cglabprojects.blogspot.com/2023/01/sierpinski-gasket-in-android-app.html