• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.example.android.apis.graphics;
18 
19 import android.app.Activity;
20 import android.graphics.PixelFormat;
21 import android.opengl.GLSurfaceView;
22 import android.os.Bundle;
23 
24 
25 /**
26  * Wrapper activity demonstrating the use of {@link GLSurfaceView} to
27  * display translucent 3D graphics.
28  */
29 public class TranslucentGLSurfaceViewActivity extends Activity {
30     @Override
onCreate(Bundle savedInstanceState)31     protected void onCreate(Bundle savedInstanceState) {
32         super.onCreate(savedInstanceState);
33 
34         // Create our Preview view and set it as the content of our
35         // Activity
36         mGLSurfaceView = new GLSurfaceView(this);
37         // We want an 8888 pixel format because that's required for
38         // a translucent window.
39         // And we want a depth buffer.
40         mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
41         // Tell the cube renderer that we want to render a translucent version
42         // of the cube:
43         mGLSurfaceView.setRenderer(new CubeRenderer(true));
44         // Use a surface format with an Alpha channel:
45         mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
46         setContentView(mGLSurfaceView);
47     }
48 
49     @Override
onResume()50     protected void onResume() {
51         super.onResume();
52         mGLSurfaceView.onResume();
53     }
54 
55     @Override
onPause()56     protected void onPause() {
57         super.onPause();
58         mGLSurfaceView.onPause();
59     }
60 
61     private GLSurfaceView mGLSurfaceView;
62 }
63 
64