Game Development Reference
In-Depth Information
The application life cycle is handled by Android itself via the onCreate method, thus
removing the need for the GLUT API calls in the ARTK. The following code illustrates this
by creating two surfaces, a camera surface described in Listing 9-2 and a GL Surface that
renders two rotating cubes (using the scenes code from Chapter 2):
CameraSurface mCameraSurface;
GLSurface mGLSurface;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mCameraSurface = new CameraSurface(this);
mGLSurface = new GLSurface(this);
mGLSurface.setRenderer(new CubeRenderer(true, false));
FrameLayout preview = ((FrameLayout) findViewById(R.id.preview));
preview.addView(mGLSurface);
preview.addView(mCameraSurface);
}
Both surfaces are added to the application layout to produce the effect of the two rotating
cubes from Chapter 2 on top of the videocam feed, as shown in Figure 9-5 .
Figure 9-5. Two rotating cubes over a video feed
Search WWH ::




Custom Search