Home | History | Annotate | Download | only in genimage
      1 /*
      2  * Copyright (C) 2013 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.android.rs.genimage;
     18 
     19 import android.app.Activity;
     20 import android.content.Context;
     21 import android.opengl.GLSurfaceView;
     22 import android.os.Bundle;
     23 
     24 public class GenImageAct extends Activity {
     25 
     26     private GLSurfaceView mGLView;
     27 
     28     @Override
     29     public void onCreate(Bundle savedInstanceState) {
     30         super.onCreate(savedInstanceState);
     31 
     32         // Create a GLSurfaceView instance and set it
     33         // as the ContentView for this Activity
     34         mGLView = new MyGLSurfaceView(this);
     35         setContentView(mGLView);
     36     }
     37 
     38     @Override
     39     protected void onPause() {
     40         super.onPause();
     41         // The following call pauses the rendering thread.
     42         // If your OpenGL application is memory intensive,
     43         // you should consider de-allocating objects that
     44         // consume significant memory here.
     45         mGLView.onPause();
     46     }
     47 
     48     @Override
     49     protected void onResume() {
     50         super.onResume();
     51         // The following call resumes a paused rendering thread.
     52         // If you de-allocated graphic objects for onPause()
     53         // this is a good place to re-allocate them.
     54         mGLView.onResume();
     55     }
     56 }
     57 
     58 class MyGLSurfaceView extends GLSurfaceView {
     59 
     60     public MyGLSurfaceView(Context context) {
     61         super(context);
     62 
     63         // Create an OpenGL ES 2.0 context.
     64         setEGLContextClientVersion(2);
     65 
     66         // Set the Renderer for drawing on the GLSurfaceView
     67         setRenderer(new GenImage(context));
     68 
     69         // Render the view only when there is a change in the drawing data
     70         setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
     71     }
     72 }
     73