Rendering the cube in ARCubeRenderer
Android provides a class called GLSurfaceView
, which is a widget that is drawn by OpenGL. The drawing logic is encapsulated via an interface called GLSurfaceView.Renderer
, which we will implement in ARCubeRenderer
. The interface requires the following methods:
onDrawFrame(GL10 gl)
: It is called to draw the current frame.onSurfaceChanged(GL10 gl, int width, int height)
: It is called when the surface size changes. For our purposes, this method does not need to do anything.onSurfaceCreated(GL10 gl, EGLConfig config)
: It is called when the surface is created or recreated. For our purposes, this method does not need to do anything.
The GL10
instance, which is passed as an argument, provides access to the standard OpenGL ES 1.0 functionality. Basically, we are interested in two kinds of OpenGL functionality; applying matrix transformations to 3D vertices and then drawing triangles based on the transformed vertices. Our cube will have eight vertices and 12...