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)
: This is called to draw the current frame. Here, we will also configure the OpenGL perspective and viewport (its drawing area on the screen) because the interfaces ofARCubeRenderer
andCameraProjectionAdapter
potentially allow the perspective to change on a frame-to-frame basis.onSurfaceChanged(GL10 gl, int width, int height)
: This is called when the surface size changes. For our purposes, this method just needs to store the width and height in member variables.onSurfaceCreated(GL10 gl, EGLConfig config)
: This is called when the surface is created or recreated. Typically, this method configures any OpenGL settings that we will not subsequently change. In other words, these...