OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Cube.java
Go to the documentation of this file.
1 /* Copyright (c) 2011-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 package com.arm.malideveloper.openglessdk.cube;
22 
23 import javax.microedition.khronos.egl.EGLConfig;
24 import javax.microedition.khronos.opengles.GL10;
25 import android.content.Context;
26 import android.opengl.GLSurfaceView;
27 import android.os.Bundle;
28 import android.view.Window;
29 import android.view.WindowManager;
30 import com.arm.malideveloper.openglessdk.*;
31 
32 class CubeView extends MaliSamplesView
33 {
34  public CubeView(Context context)
35  {
36  super(context);
37  }
38 
39  @Override protected void setRendererCallback()
40  {
41  setRenderer(new Renderer());
42  }
43 
44  @Override protected void destroyContextCallback()
45  {
46  Cube.uninit();
47  }
48 
49  protected class Renderer implements GLSurfaceView.Renderer
50  {
51  public void onDrawFrame(GL10 gl)
52  {
53  Cube.step();
54  }
55 
56  public void onSurfaceChanged(GL10 gl, int width, int height)
57  {
58  Cube.init(width, height);
59  }
60 
61  public void onSurfaceCreated(GL10 gl, EGLConfig config)
62  {
63  }
64  }
65 };
66 
67 public class Cube extends MaliSamplesActivity
68 {
69  CubeView mView;
70 
71  public static native void init(int width, int height);
72  public static native void step();
73  public static native void uninit();
74 
75  @Override protected void onCreate(Bundle savedInstanceState)
76  {
77  super.onCreate(savedInstanceState);
78 
79  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
80  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
81  WindowManager.LayoutParams.FLAG_FULLSCREEN);
82 
83  mView = new CubeView(getApplication());
84  setContentView(mView);
85  }
86 
87  @Override protected void onPause()
88  {
89  super.onPause();
90  mView.onPause();
91  }
92 
93  @Override protected void onResume()
94  {
95  super.onResume();
96  mView.onResume();
97  }
98 
99  @Override protected void onDestroy()
100  {
101  super.onDestroy();
102  }
103 
104  static
105  {
106  // Load the NDK library for this example, built with ndk-build
107  System.loadLibrary("Native");
108  }
109 }
110 
111 
GLint GLsizei GLsizei height
Definition: gl2ext.h:179
void onSurfaceChanged(GL10 gl, int width, int height)
Definition: Cube.java:56
void onSurfaceCreated(GL10 gl, EGLConfig config)
Definition: Cube.java:61
void onCreate(Bundle savedInstanceState)
Definition: Cube.java:75
GLint GLsizei width
Definition: gl2ext.h:179
static native void init(int width, int height)