Game Development Reference
In-Depth Information
Figure 5-3. Workflow of the Java-only cubes sample
Java Main Activity
When the user starts the application, the JavaGLActivity.onCreate() method will be called (see Listing 5-2).
Here is where the surface view ( mGLSurfaceView ) is initialized and set as the application content:
mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setRenderer(new CubeRenderer(true));
setContentView(mGLSurfaceView);
Note that the GL surface view must use a renderer ( CubeRenderer in this case), which implements
the Renderer interface and takes a Boolean argument indicating if a translucent background should be
used.
Listing 5-2. Main Activity for the Java-Only Version of the GL Cubes Sample
package opengl.test;
import opengl.scenes.GLSurfaceView;
import opengl.scenes.cubes.CubeRenderer;
import android.app.Activity;
import android.os.Bundle;
public class JavaGLActivity extends Activity
{
Search WWH ::




Custom Search