OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HighQualityTextJava.java
Go to the documentation of this file.
1 /* Copyright (c) 2013-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.highqualitytextjava;
22 
24 
25 import android.app.Activity;
26 import android.opengl.GLSurfaceView;
27 import android.os.Bundle;
28 import android.content.*;
29 import android.view.*;
30 
31 public class HighQualityTextJava extends Activity {
32 
33  // This is the view used to render to it.
34  private GLSurfaceView GLES20SurfaceView;
35 
36  // Called when the activity is first created.
37  @Override
38  public void onCreate(Bundle savedInstanceState) {
39  super.onCreate(savedInstanceState);
40 
41  // Assume GLES20 rendering is available on the device
42 
43  // SetUp the Surface view for the activity
44  GLES20SurfaceView = new HighQualityTextSurfaceView(this);
45  setContentView(GLES20SurfaceView);
46  }
47 
48  @Override
49  public void onPause() {
50  super.onPause();
51  GLES20SurfaceView.onPause();
52  }
53 
54  @Override
55  public void onResume() {
56  super.onResume();
57  GLES20SurfaceView.onResume();
58  }
59 }
60 
61 class HighQualityTextSurfaceView extends GLSurfaceView {
62 
63  private HighQualityTextRenderer theRenderer = new HighQualityTextRenderer();
64  private float prevX = 0.0f;
65  private float prevY = 0.0f;
66 
67  public HighQualityTextSurfaceView(Context context){
68  super(context);
69 
70  setEGLConfigChooser(false);
71  // Create an OpenGL ES 2.0 context.
72  setEGLContextClientVersion(2);
73  // Set the Renderer for drawing on the GLSurfaceView
74  setRenderer(theRenderer);
75  }
76 
77  public boolean onTouchEvent (MotionEvent event) {
78  if (event.getAction() == MotionEvent.ACTION_DOWN) {
79  prevX = event.getRawX();
80  prevY = event.getRawY();
81  theRenderer.touchDown(prevX, prevY);
82  }
83  if (event.getAction() == MotionEvent.ACTION_UP) {
84  theRenderer.touchUp(event.getRawX(), event.getRawY());
85  }
86  if (event.getAction() == MotionEvent.ACTION_MOVE) {
87  float x = event.getRawX();
88  float y = event.getRawY();
89  theRenderer.touchMove(x, y, prevX, prevY);
90  prevX = x;
91  prevY = y;
92  }
93  return true;
94  }
95 }
GLint GLint GLint GLint GLint x
Definition: gl2ext.h:574
GLint y
Definition: gl2ext.h:179