OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProceduralGeometryView.java
Go to the documentation of this file.
1 /* Copyright (c) 2015-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.proceduralgeometry;
22 
23 import android.content.Context;
24 import android.graphics.PixelFormat;
25 import android.opengl.GLSurfaceView;
26 import android.util.AttributeSet;
27 import android.util.Log;
28 import android.view.KeyEvent;
29 import android.view.MotionEvent;
30 
31 import javax.microedition.khronos.egl.EGL10;
32 import javax.microedition.khronos.egl.EGLConfig;
33 import javax.microedition.khronos.egl.EGLContext;
34 import javax.microedition.khronos.egl.EGLDisplay;
35 import javax.microedition.khronos.opengles.GL10;
36 
37 class ProceduralGeometryView extends GLSurfaceView {
38  private static final String TAG = "ProceduralGeometry";
39  private static final boolean DEBUG = true;
40 
41  public ProceduralGeometryView(Context context) {
42  super(context);
43  setEGLConfigChooser(8, 8, 8, 0, 16, 0);
44  setEGLContextClientVersion(2);
45  setRenderer(new Renderer());
46  }
47 
48  public boolean onTouchEvent(MotionEvent event)
49  {
50  float x = event.getRawX();
51  float y = event.getRawY();
52 
53  if (event.getAction() == MotionEvent.ACTION_UP)
54  ProceduralGeometry.onpointerup(x, y);
55  else if (event.getAction() == MotionEvent.ACTION_MOVE)
56  ProceduralGeometry.onpointerdown(x, y);
57  return true;
58  }
59 
60  private static class Renderer implements GLSurfaceView.Renderer {
61  public void onDrawFrame(GL10 gl) {
62  ProceduralGeometry.step();
63  }
64 
65  public void onSurfaceChanged(GL10 gl, int width, int height) {
66  ProceduralGeometry.resize(width, height);
67  }
68 
69  public void onSurfaceCreated(GL10 gl, EGLConfig config) {
70  ProceduralGeometry.init();
71  }
72  }
73 }
GLint GLsizei GLsizei height
Definition: gl2ext.h:179
GLint GLint GLint GLint GLint x
Definition: gl2ext.h:574
GLint GLsizei width
Definition: gl2ext.h:179
GLint y
Definition: gl2ext.h:179