OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ThreadSync.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.threadsync;
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 import android.view.MotionEvent;
32 import android.view.View;
33 import android.view.View.OnTouchListener;
34 
35 class ThreadSyncView extends MaliSamplesView
36 {
37  public ThreadSyncView(Context context, MaliSamplesView.GlesVersion version)
38  {
39  super(context, version);
40  }
41 
42  @Override protected void setRendererCallback()
43  {
44  setRenderer(new Renderer());
45  }
46 
47  @Override protected void destroyContextCallback()
48  {
49  ThreadSync.uninit();
50  }
51 
52  protected class Renderer implements GLSurfaceView.Renderer
53  {
54  public void onDrawFrame(GL10 gl)
55  {
56  ThreadSync.step();
57  }
58 
59  public void onSurfaceChanged(GL10 gl, int width, int height)
60  {
61  ThreadSync.init(width, height);
62  }
63 
64  public void onSurfaceCreated(GL10 gl, EGLConfig config)
65  {
66  // Optional code here...
67  }
68  }
69 };
70 
71 public class ThreadSync extends MaliSamplesActivity implements OnTouchListener
72 {
73  ThreadSyncView mView;
74 
75  public static native void init(int width, int height);
76  public static native void step();
77  public static native void uninit();
78 
79  public static native void touchStart(int x, int y);
80  public static native void touchMove (int x, int y);
81  public static native void touchEnd (int x, int y);
82 
83  @Override protected void onCreate(Bundle icicle)
84  {
85  super.onCreate(icicle);
86 
87  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
88  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
89  WindowManager.LayoutParams.FLAG_FULLSCREEN);
90 
91  mView = new ThreadSyncView(getApplication(),MaliSamplesView.GlesVersion.GLES3);
92  setContentView(mView);
93  }
94 
95  @Override protected void onPause()
96  {
97  super.onPause();
98  mView.onPause();
99  }
100 
101  @Override protected void onResume()
102  {
103  super.onResume();
104  mView.onResume();
105  }
106 
107  @Override protected void onDestroy()
108  {
109  super.onDestroy();
110  }
111 
112  static
113  {
114  // Load the NDK library for this example, built with ndk-build
115  System.loadLibrary("Native");
116  }
117 
118  @Override public boolean onTouch(View v, MotionEvent event)
119  {
120  //Log.d( "ThreadSync Fur", "onTouch" );
121  // TODO Auto-generated method stub
122  return false;
123  }
124 
125  @Override public boolean onTouchEvent(MotionEvent event)
126  {
127  //Log.i( "Fur", "onTouchEvent" );
128  switch (event.getAction())
129  {
130  case MotionEvent.ACTION_DOWN:
131  //Log.i( "Dials", "onTouchEvent/DOWN" );
132  touchStart((int)event.getX(),(int)event.getY());
133  break;
134  case MotionEvent.ACTION_MOVE:
135  //Log.i( "Dials", "onTouchEvent/MOVE" );
136  touchMove((int)event.getX(),(int)event.getY());
137  break;
138 
139  case MotionEvent.ACTION_UP:
140  //Log.i( "Dials", "onTouchEvent/UP" );
141  touchEnd((int)event.getX(),(int)event.getY());
142  break;
143  default:
144  break;
145  }
146  return true;
147  }
148 
149 
150 }
151 
152 
const GLfloat * v
Definition: gl2ext.h:2231
static native void init(int width, int height)
GLint GLsizei GLsizei height
Definition: gl2ext.h:179
precision highp int
Definition: hiz_cull.cs:38
GLint GLint GLint GLint GLint x
Definition: gl2ext.h:574
GLint GLsizei width
Definition: gl2ext.h:179
GLint y
Definition: gl2ext.h:179