I searched a lot in the internet to find an example simple enough with the basic rotation and translation in Android OpenGL ES 2.0. Since i am not quiet happy with the ones there i decided to write on my own with help from a bunch of code out there in internet.
If you right away want to try out the example, try it here. .https://github.com/soundarmoorthy/androidopenglsimple_intro
It has basically 3 files.
This class contains the the entry point for the app, where i add all the UI elements which will be used to control the rendering of the line. You have six buttons which controls, the x, y, z coordinates of the rendered line and roll, pitch, yaw which controls the angle of rotation of the line in the respective x,y,z axis. It also registers our rendering class (MyRenderer) with the android system so that methods in our class is called back by the android system for drawing.
This basically is the class that implements the rendering. It has three elements
- OnSurfaceCreated - Called when the surface is initialized for the first time
- OnSurfaceChanged - Called when the display size / orientation changes
- OnDrawFrame - Called each time we need to draw something. This is quiet resource intensive.
This class defines the coordinates, attributes of the line geometry. It also defines and loads the vector graphic into the GPU memory.