1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.example.android.apis.graphics;
18
19import android.app.Activity;
20import android.opengl.GLSurfaceView;
21import android.os.Bundle;
22
23/**
24 * Wrapper activity demonstrating the use of {@link GLSurfaceView}, a view
25 * that uses OpenGL drawing into a dedicated surface.
26 */
27public class GLSurfaceViewActivity extends Activity {
28    @Override
29    protected void onCreate(Bundle savedInstanceState) {
30        super.onCreate(savedInstanceState);
31
32        // Create our Preview view and set it as the content of our
33        // Activity
34        mGLSurfaceView = new GLSurfaceView(this);
35        mGLSurfaceView.setRenderer(new CubeRenderer(false));
36        setContentView(mGLSurfaceView);
37    }
38
39    @Override
40    protected void onResume() {
41        // Ideally a game should implement onResume() and onPause()
42        // to take appropriate action when the activity looses focus
43        super.onResume();
44        mGLSurfaceView.onResume();
45    }
46
47    @Override
48    protected void onPause() {
49        // Ideally a game should implement onResume() and onPause()
50        // to take appropriate action when the activity looses focus
51        super.onPause();
52        mGLSurfaceView.onPause();
53    }
54
55    private GLSurfaceView mGLSurfaceView;
56}
57