Project

General

Profile

« Previous | Next » 

Revision 41a81a14

Added by Leszek Koltunski over 7 years ago

Try using OpenGL ES 3.0 everywhere (but if device does not support it, try creating 2.0 context - this is important because of the emulator!)

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES20;
24
import android.opengl.GLES30;
25 25
import android.opengl.GLSurfaceView;
26 26

  
27 27
import org.distorted.examples.R;
......
76 76

  
77 77
   public void onDrawFrame(GL10 glUnused) 
78 78
      {
79
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
79
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
80 80
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
81 81
      }
82 82

  
......
108 108
    
109 109
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
110 110
      {
111
      GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
111
      GLES30.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
112 112

  
113 113
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.face);
114 114
      Bitmap bitmap;
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRendererPicker.java
26 26
import javax.microedition.khronos.egl.EGLConfig;
27 27
import javax.microedition.khronos.opengles.GL10;
28 28

  
29
import android.opengl.GLES20;
29
import android.opengl.GLES30;
30 30
import android.opengl.GLSurfaceView;
31 31
import android.opengl.Matrix;
32 32

  
......
105 105

  
106 106
	@Override public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
107 107
	  {
108
		GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
108
		GLES30.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
109 109

  
110 110
		final float eyeX = 0.0f;
111 111
		final float eyeY = 0.0f;
......
142 142
		  + "  gl_FragColor = v_Color;    \n"
143 143
		  + "  }                          \n";
144 144

  
145
		int vertexShaderHandle = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
145
		int vertexShaderHandle = GLES30.glCreateShader(GLES30.GL_VERTEX_SHADER);
146 146

  
147 147
		if (vertexShaderHandle != 0)
148 148
		  {
149
			GLES20.glShaderSource(vertexShaderHandle, vertexShader);
150
      GLES20.glCompileShader(vertexShaderHandle);
149
			GLES30.glShaderSource(vertexShaderHandle, vertexShader);
150
      GLES30.glCompileShader(vertexShaderHandle);
151 151

  
152 152
      final int[] compileStatus = new int[1];
153
			GLES20.glGetShaderiv(vertexShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
153
			GLES30.glGetShaderiv(vertexShaderHandle, GLES30.GL_COMPILE_STATUS, compileStatus, 0);
154 154

  
155 155
			if (compileStatus[0] == 0)
156 156
  			{
157
				GLES20.glDeleteShader(vertexShaderHandle);
157
				GLES30.glDeleteShader(vertexShaderHandle);
158 158
				vertexShaderHandle = 0;
159 159
	  		}
160 160
		  }
......
164 164
			throw new RuntimeException("Error creating vertex shader.");
165 165
		  }
166 166

  
167
		int fragmentShaderHandle = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
167
		int fragmentShaderHandle = GLES30.glCreateShader(GLES30.GL_FRAGMENT_SHADER);
168 168

  
169 169
		if (fragmentShaderHandle != 0)
170 170
		  {
171
			GLES20.glShaderSource(fragmentShaderHandle, fragmentShader);
172
      GLES20.glCompileShader(fragmentShaderHandle);
171
			GLES30.glShaderSource(fragmentShaderHandle, fragmentShader);
172
      GLES30.glCompileShader(fragmentShaderHandle);
173 173

  
174 174
			final int[] compileStatus = new int[1];
175
			GLES20.glGetShaderiv(fragmentShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
175
			GLES30.glGetShaderiv(fragmentShaderHandle, GLES30.GL_COMPILE_STATUS, compileStatus, 0);
176 176

  
177 177
			if (compileStatus[0] == 0)
178 178
			  {
179
				GLES20.glDeleteShader(fragmentShaderHandle);
179
				GLES30.glDeleteShader(fragmentShaderHandle);
180 180
				fragmentShaderHandle = 0;
181 181
			  }
182 182
		  }
......
186 186
			throw new RuntimeException("Error creating fragment shader.");
187 187
		  }
188 188

  
189
		int programHandle = GLES20.glCreateProgram();
189
		int programHandle = GLES30.glCreateProgram();
190 190

  
191 191
		if (programHandle != 0)
192 192
		  {
193
			GLES20.glAttachShader(programHandle, vertexShaderHandle);
194
      GLES20.glAttachShader(programHandle, fragmentShaderHandle);
195
			GLES20.glBindAttribLocation(programHandle, 0, "a_Position");
196
			GLES20.glBindAttribLocation(programHandle, 1, "a_Color");
197
			GLES20.glLinkProgram(programHandle);
193
			GLES30.glAttachShader(programHandle, vertexShaderHandle);
194
      GLES30.glAttachShader(programHandle, fragmentShaderHandle);
195
			GLES30.glBindAttribLocation(programHandle, 0, "a_Position");
196
			GLES30.glBindAttribLocation(programHandle, 1, "a_Color");
197
			GLES30.glLinkProgram(programHandle);
198 198

  
199 199
			final int[] linkStatus = new int[1];
200
			GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);
200
			GLES30.glGetProgramiv(programHandle, GLES30.GL_LINK_STATUS, linkStatus, 0);
201 201

  
202 202
			if (linkStatus[0] == 0)
203 203
			  {
204
				GLES20.glDeleteProgram(programHandle);
204
				GLES30.glDeleteProgram(programHandle);
205 205
				programHandle = 0;
206 206
			  }
207 207
		  }
......
211 211
			throw new RuntimeException("Error creating program.");
212 212
		  }
213 213

  
214
    mMVPMatrixH = GLES20.glGetUniformLocation(programHandle, "u_MVPMatrix");
215
    mPositionH  = GLES20.glGetAttribLocation(programHandle, "a_Position");
216
    mColorH     = GLES20.glGetAttribLocation(programHandle, "a_Color");
214
    mMVPMatrixH = GLES30.glGetUniformLocation(programHandle, "u_MVPMatrix");
215
    mPositionH  = GLES30.glGetAttribLocation(programHandle, "a_Position");
216
    mColorH     = GLES30.glGetAttribLocation(programHandle, "a_Color");
217 217

  
218
    GLES20.glUseProgram(programHandle);
218
    GLES30.glUseProgram(programHandle);
219 219
	  }
220 220

  
221 221
///////////////////////////////////////////////////////////////////////////////////////////////////
......
225 225
	  mHeight = height;
226 226
	  mWidth  = width;
227 227

  
228
		GLES20.glViewport(0, 0, width, height);
228
		GLES30.glViewport(0, 0, width, height);
229 229

  
230 230
		final float ratio  = (float) width / height;
231 231
		final float left   =-ratio;
......
243 243

  
244 244
	@Override public void onDrawFrame(GL10 glUnused)
245 245
	  {
246
		GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
247
    GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPTriangleMatrix, 0);
246
		GLES30.glClear(GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
247
    GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPTriangleMatrix, 0);
248 248

  
249 249
    ///////// 'white-black-yellow' triangle //////
250 250
    mTriangleVert.position(POSITION_OFFSET);
251
    GLES20.glVertexAttribPointer(mPositionH, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, STRIDE_BYTES, mTriangleVert);
252
    GLES20.glEnableVertexAttribArray(mPositionH);
251
    GLES30.glVertexAttribPointer(mPositionH, POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, STRIDE_BYTES, mTriangleVert);
252
    GLES30.glEnableVertexAttribArray(mPositionH);
253 253
    mTriangleVert.position(COLOR_OFFSET);
254
    GLES20.glVertexAttribPointer(mColorH, COLOR_DATA_SIZE, GLES20.GL_FLOAT, false, STRIDE_BYTES, mTriangleVert);
255
    GLES20.glEnableVertexAttribArray(mColorH);
254
    GLES30.glVertexAttribPointer(mColorH, COLOR_DATA_SIZE, GLES30.GL_FLOAT, false, STRIDE_BYTES, mTriangleVert);
255
    GLES30.glEnableVertexAttribArray(mColorH);
256 256

  
257
		GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPTriangleMatrix, 0);
258
		GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
257
		GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPTriangleMatrix, 0);
258
		GLES30.glDrawArrays(GLES30.GL_TRIANGLES, 0, 3);
259 259

  
260 260
    //////// 'current position' square ///////////
261 261
    mSquareVert.position(POSITION_OFFSET);
262
    GLES20.glVertexAttribPointer(mPositionH, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, STRIDE_BYTES, mSquareVert);
263
    GLES20.glEnableVertexAttribArray(mPositionH);
262
    GLES30.glVertexAttribPointer(mPositionH, POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, STRIDE_BYTES, mSquareVert);
263
    GLES30.glEnableVertexAttribArray(mPositionH);
264 264
    mSquareVert.position(COLOR_OFFSET);
265
    GLES20.glVertexAttribPointer(mColorH, COLOR_DATA_SIZE, GLES20.GL_FLOAT, false, STRIDE_BYTES, mSquareVert);
266
    GLES20.glEnableVertexAttribArray(mColorH);
265
    GLES30.glVertexAttribPointer(mColorH, COLOR_DATA_SIZE, GLES30.GL_FLOAT, false, STRIDE_BYTES, mSquareVert);
266
    GLES30.glEnableVertexAttribArray(mColorH);
267 267

  
268 268
    Matrix.multiplyMM(mMVPSquareMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
269 269
    Matrix.multiplyMM(mMVPSquareMatrix, 0, mProjectionMatrix, 0, mMVPSquareMatrix, 0);
270 270

  
271
    GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPSquareMatrix, 0);
272
		GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0,4);
271
    GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPSquareMatrix, 0);
272
		GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0,4);
273 273
	  }
274 274
  }
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceView.java
19 19

  
20 20
package org.distorted.examples.aroundtheworld;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35

  
34
    public AroundTheWorldSurfaceView(Context c, AttributeSet attrs)
36
    public AroundTheWorldSurfaceView(Context context, AttributeSet attrs)
35 37
      {
36
      super(c, attrs);
38
      super(context, attrs);
37 39

  
38 40
      if(!isInEditMode())
39 41
        {
40
        setEGLContextClientVersion(2);
42
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
43
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
44
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
41 46
        mRenderer = new AroundTheWorldRenderer(this);
42 47
        setRenderer(mRenderer);
43 48
        }
44 49
      }
50

  
45 51
///////////////////////////////////////////////////////////////////////////////////////////////////
46 52

  
47 53
    public AroundTheWorldEffectsManager getManager()
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceViewPicker.java
19 19

  
20 20
package org.distorted.examples.aroundtheworld;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27
import android.view.MotionEvent;
......
33 35

  
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
35 37

  
36
    public AroundTheWorldSurfaceViewPicker(Context c, AttributeSet attrs)
38
    public AroundTheWorldSurfaceViewPicker(Context context, AttributeSet attrs)
37 39
      {
38
      super(c, attrs);
40
      super(context, attrs);
39 41

  
40 42
      if(!isInEditMode())
41 43
        {
42
        setEGLContextClientVersion(2);
44
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
45
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
46
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
47
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
43 48
        mRenderer = new AroundTheWorldRendererPicker();
44 49
        setRenderer(mRenderer);
45 50
        }
src/main/java/org/distorted/examples/bean/BeanRenderer.java
39 39

  
40 40
import android.graphics.Bitmap;
41 41
import android.graphics.BitmapFactory;
42
import android.opengl.GLES20;
42
import android.opengl.GLES30;
43 43
import android.opengl.GLSurfaceView;
44 44

  
45 45
///////////////////////////////////////////////////////////////////////////////////////////////////
......
96 96
   
97 97
    public void onDrawFrame(GL10 glUnused) 
98 98
      {
99
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
99
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
100 100
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
101 101
      }
102 102

  
......
130 130
    
131 131
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
132 132
      {
133
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
133
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
134 134

  
135 135
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.bean);
136 136
      Bitmap bitmap;
src/main/java/org/distorted/examples/bean/BeanSurfaceView.java
19 19

  
20 20
package org.distorted.examples.bean;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.os.Build;
25 27

  
......
32 34
    public BeanSurfaceView(Context context) 
33 35
      {
34 36
      super(context);
35
      setEGLContextClientVersion(2);
37
      final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
38
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
39
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
40
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
36 41
      setRenderer(new BeanRenderer(this));
37 42
      }
38 43
}
src/main/java/org/distorted/examples/blur/BlurRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES20;
24
import android.opengl.GLES30;
25 25
import android.opengl.GLSurfaceView;
26 26

  
27 27
import org.distorted.examples.R;
......
82 82
   
83 83
   public void onDrawFrame(GL10 glUnused) 
84 84
      {
85
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
85
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
86 86
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
87 87
      }
88 88

  
......
116 116
    
117 117
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
118 118
      {
119
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
119
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
120 120

  
121 121
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
122 122
      Bitmap bitmap;
src/main/java/org/distorted/examples/blur/BlurSurfaceView.java
19 19

  
20 20
package org.distorted.examples.blur;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35

  
34
  public BlurSurfaceView(Context c, AttributeSet attrs)
36
  public BlurSurfaceView(Context context, AttributeSet attrs)
35 37
      {
36
      super(c, attrs);
38
      super(context, attrs);
37 39

  
38 40
      if(!isInEditMode())
39 41
        {
40
        setEGLContextClientVersion(2);
42
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
43
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
44
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
41 46
        mRenderer = new BlurRenderer(this);
42 47
        setRenderer(mRenderer);
43 48
        }
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
40 40

  
41 41
import android.graphics.Bitmap;
42 42
import android.graphics.BitmapFactory;
43
import android.opengl.GLES20;
43
import android.opengl.GLES30;
44 44
import android.opengl.GLSurfaceView;
45 45

  
46 46
///////////////////////////////////////////////////////////////////////////////////////////////////
......
85 85
   
86 86
    public void onDrawFrame(GL10 glUnused) 
87 87
      {
88
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
88
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
89 89
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
90 90
      }
91 91

  
......
93 93
    
94 94
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
95 95
      {
96
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
96
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
97 97

  
98 98
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.cat_and_dog);
99 99
      Bitmap bitmap;
src/main/java/org/distorted/examples/catanddog/CatAndDogSurfaceView.java
19 19

  
20 20
package org.distorted.examples.catanddog;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
......
31 33
    public CatAndDogSurfaceView(Context context)
32 34
      {
33 35
      super(context);
34
      setEGLContextClientVersion(2);
36
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
37
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
38
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
39
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
35 40
      setRenderer(new CatAndDogRenderer(this));
36 41
      }
37 42
}
src/main/java/org/distorted/examples/check/CheckRenderer.java
44 44
import android.content.DialogInterface;
45 45
import android.graphics.Bitmap;
46 46
import android.graphics.BitmapFactory;
47
import android.opengl.GLES20;
47
import android.opengl.GLES30;
48 48
import android.opengl.GLSurfaceView;
49 49
import android.util.Log;
50 50

  
......
81 81
   
82 82
    public void onDrawFrame(GL10 glUnused) 
83 83
      {
84
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
84
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
85 85
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
86 86
      }
87 87

  
......
115 115
    
116 116
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
117 117
      {  
118
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
118
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
119 119

  
120 120
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.success);
121 121
      Bitmap bitmap;
......
196 196
      
197 197
        String ver;
198 198
      
199
        ver = GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION);   
199
        ver = GLES30.glGetString(GLES30.GL_SHADING_LANGUAGE_VERSION);   
200 200
        compilationResult += "\n\nGLSL version: "+(ver==null ? "null" : ver);
201
        ver = GLES20.glGetString(GLES20.GL_VERSION);  
201
        ver = GLES30.glGetString(GLES30.GL_VERSION);  
202 202
        compilationResult += "\nGL version: "+(ver==null ? "null" : ver);
203
        ver = GLES20.glGetString(GLES20.GL_VENDOR);   
203
        ver = GLES30.glGetString(GLES30.GL_VENDOR);   
204 204
        compilationResult += "\nGL vendor: "+(ver==null ? "null" : ver);
205
        ver = GLES20.glGetString(GLES20.GL_RENDERER);    
205
        ver = GLES30.glGetString(GLES30.GL_RENDERER);    
206 206
        compilationResult += "\nGL renderer: "+(ver==null ? "null" : ver);
207 207
      
208 208
        CheckActivity act = (CheckActivity)mView.getContext();
src/main/java/org/distorted/examples/check/CheckSurfaceView.java
19 19

  
20 20
package org.distorted.examples.check;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
29 31
{
30 32
///////////////////////////////////////////////////////////////////////////////////////////////////
31 33
   
32
    public CheckSurfaceView(Context c, AttributeSet attrs) 
34
    public CheckSurfaceView(Context context, AttributeSet attrs)
33 35
      {
34
      super(c, attrs);
36
      super(context, attrs);
35 37
    
36 38
      if(!isInEditMode())
37 39
        {
38
        setEGLContextClientVersion(2);
40
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
41
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
42
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
43
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
39 44
        setRenderer(new CheckRenderer(this));
40 45
        }
41 46
      }
42 47

  
43 48
}
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

  
src/main/java/org/distorted/examples/cubes/CubesRenderer.java
39 39

  
40 40
import android.graphics.Bitmap;
41 41
import android.graphics.BitmapFactory;
42
import android.opengl.GLES20;
42
import android.opengl.GLES30;
43 43
import android.opengl.GLSurfaceView;
44 44

  
45 45
///////////////////////////////////////////////////////////////////////////////////////////////////
......
88 88
   
89 89
    public void onDrawFrame(GL10 glUnused) 
90 90
      {
91
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
91
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
92 92
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
93 93
      }
94 94

  
......
124 124
    
125 125
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
126 126
      {
127
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
127
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
128 128

  
129 129
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.grid);
130 130
      Bitmap bitmap;
src/main/java/org/distorted/examples/cubes/CubesSurfaceView.java
21 21

  
22 22
import org.distorted.examples.R;
23 23

  
24
import android.app.ActivityManager;
24 25
import android.content.Context;
26
import android.content.pm.ConfigurationInfo;
25 27
import android.opengl.GLSurfaceView;
26 28
import android.util.AttributeSet;
27 29
import android.view.MotionEvent;
......
36 38
	
37 39
///////////////////////////////////////////////////////////////////////////////////////////////////
38 40
   
39
    public CubesSurfaceView(Context c, AttributeSet attrs) 
41
    public CubesSurfaceView(Context context, AttributeSet attrs)
40 42
      {
41
      super(c,attrs);
43
      super(context,attrs);
42 44
    
43 45
      mX = -1;
44 46
      mY = -1;
45 47
      
46 48
      if(!isInEditMode())
47 49
        {
48
        setEGLContextClientVersion(2);
50
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
51
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
52
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
53
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
49 54
        mRenderer = new CubesRenderer(this);
50 55
        setRenderer(mRenderer);
51
        Toast.makeText(c, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show();
56
        Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show();
52 57
        }
53 58
      }
54 59
    
src/main/java/org/distorted/examples/deform/DeformRenderer.java
39 39
import android.graphics.Canvas;
40 40
import android.graphics.Paint;
41 41
import android.graphics.Paint.Style;
42
import android.opengl.GLES20;
42
import android.opengl.GLES30;
43 43
import android.opengl.GLSurfaceView;
44 44

  
45 45
///////////////////////////////////////////////////////////////////////////////////////////////////
......
180 180
   
181 181
   public void onDrawFrame(GL10 glUnused)
182 182
     {
183
     GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
183
     GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
184 184
    
185 185
     long time = System.currentTimeMillis();
186 186
      
......
229 229
    
230 230
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
231 231
     {
232
     GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
232
     GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
233 233

  
234 234
     try
235 235
       {
src/main/java/org/distorted/examples/deform/DeformSurfaceView.java
19 19

  
20 20
package org.distorted.examples.deform;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27
import android.view.MotionEvent;
......
33 35
   
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
35 37
   
36
    public DeformSurfaceView(Context c, AttributeSet attrs) 
38
    public DeformSurfaceView(Context context, AttributeSet attrs)
37 39
      {
38
      super(c, attrs);
40
      super(context, attrs);
39 41
    
40 42
      if(!isInEditMode())
41 43
        {
42
        setEGLContextClientVersion(2);
44
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
45
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
46
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
47
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
43 48
        mRenderer = new DeformRenderer(this);
44 49
        setRenderer(mRenderer);
45 50
        }
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java
40 40

  
41 41
import android.graphics.Bitmap;
42 42
import android.graphics.BitmapFactory;
43
import android.opengl.GLES20;
43
import android.opengl.GLES30;
44 44
import android.opengl.GLSurfaceView;
45 45

  
46 46
///////////////////////////////////////////////////////////////////////////////////////////////////
......
107 107
   
108 108
    public void onDrawFrame(GL10 glUnused) 
109 109
      {
110
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
110
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
111 111
      
112 112
      long time = System.currentTimeMillis();
113 113
      
......
154 154
    
155 155
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
156 156
      {
157
      GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
157
      GLES30.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
158 158

  
159 159
      Bitmap bitmap0= readBitmap(R.raw.dog);
160 160
      Bitmap bitmap1= readBitmap(R.raw.face);
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsSurfaceView.java
19 19

  
20 20
package org.distorted.examples.differentbitmaps;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
......
31 33
    public DifferentBitmapsSurfaceView(Context context) 
32 34
      {
33 35
      super(context);
34
      setEGLContextClientVersion(2);
36
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
37
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
38
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
39
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
35 40
      setRenderer(new DifferentBitmapsRenderer(this));
36 41
      }
37 42
}
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
41 41

  
42 42
import android.graphics.Bitmap;
43 43
import android.graphics.BitmapFactory;
44
import android.opengl.GLES20;
44
import android.opengl.GLES30;
45 45
import android.opengl.GLSurfaceView;
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
101 101
   
102 102
   public void onDrawFrame(GL10 glUnused)
103 103
     {
104
     GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
104
     GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
105 105
      
106 106
     long time = System.currentTimeMillis();
107 107
   
......
148 148
    
149 149
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
150 150
     {
151
     GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
151
     GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
152 152

  
153 153
     InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
154 154
     Bitmap bitmap;
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsSurfaceView.java
19 19

  
20 20
package org.distorted.examples.differenteffects;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
......
31 33
    public DifferentEffectsSurfaceView(Context context) 
32 34
      {
33 35
      super(context);
34
      setEGLContextClientVersion(2);
36
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
37
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
38
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
39
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
35 40
      setRenderer(new DifferentEffectsRenderer(this));
36 41
      }
37 42
}
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java
26 26
import android.graphics.Canvas;
27 27
import android.graphics.Paint;
28 28
import android.graphics.Paint.Style;
29
import android.opengl.GLES20;
29
import android.opengl.GLES30;
30 30
import android.opengl.GLSurfaceView;
31 31

  
32 32
import org.distorted.library.DistortedEffects;
......
99 99
   
100 100
   public void onDrawFrame(GL10 glUnused)
101 101
     {   
102
     GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);               
102
     GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT | GLES30.GL_DEPTH_BUFFER_BIT);               
103 103
       
104 104
     long time = System.currentTimeMillis();
105 105
      
src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java
19 19

  
20 20
package org.distorted.examples.dynamic;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.view.MotionEvent;
25 27
import android.util.AttributeSet;
......
76 78
      
77 79
///////////////////////////////////////////////////////////////////
78 80
    
79
    public DynamicSurfaceView(Context c, AttributeSet attrs)
81
    public DynamicSurfaceView(Context context, AttributeSet attrs)
80 82
      {
81
      super(c, attrs);
83
      super(context, attrs);
82 84
      
83 85
      mPaint = new Paint();
84 86
      mPaint.setStyle(Style.FILL);
......
108 110
        {
109 111
        setFocusable(true);
110 112
        setFocusableInTouchMode(true);
111
        setEGLContextClientVersion(2);
113
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
114
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
115
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
116
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
112 117
        DynamicRenderer mRenderer = new DynamicRenderer(this);
113 118
        setRenderer(mRenderer);
114 119
        }
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java
26 26
import android.graphics.Canvas;
27 27
import android.graphics.Paint;
28 28
import android.graphics.Paint.Style;
29
import android.opengl.GLES20;
29
import android.opengl.GLES30;
30 30
import android.opengl.GLSurfaceView;
31 31

  
32 32
import org.distorted.library.DistortedEffects;
......
129 129
   
130 130
  public void onDrawFrame(GL10 glUnused)
131 131
    {   
132
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
132
    GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT | GLES30.GL_DEPTH_BUFFER_BIT);
133 133
    mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
134 134
    }
135 135

  
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java
19 19

  
20 20
package org.distorted.examples.effectqueue;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.view.MotionEvent;
25 27
import android.util.AttributeSet;
......
49 51

  
50 52
///////////////////////////////////////////////////////////////////////////////////////////////////
51 53
    
52
  public EffectQueueSurfaceView(Context c, AttributeSet attrs)
54
  public EffectQueueSurfaceView(Context context, AttributeSet attrs)
53 55
    {
54
    super(c, attrs);
56
    super(context, attrs);
55 57
      
56 58
    int duration = 10000;
57 59
    float count  = 1.0f;
......
85 87
      {
86 88
      setFocusable(true);
87 89
      setFocusableInTouchMode(true);
88
      setEGLContextClientVersion(2);
90
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
91
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
92
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
93
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
89 94

  
90 95
      mRenderer = new EffectQueueRenderer(this);
91 96
      setRenderer(mRenderer);
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES20;
24
import android.opengl.GLES30;
25 25
import android.opengl.GLSurfaceView;
26 26

  
27 27
import org.distorted.examples.R;
......
133 133

  
134 134
    public void onDrawFrame(GL10 glUnused)
135 135
      {
136
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
136
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
137 137

  
138 138
      long time = System.currentTimeMillis();
139 139

  
......
221 221

  
222 222
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
223 223
      {
224
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
224
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
225 225

  
226 226
      Effects3DActivity act = (Effects3DActivity)mView.getContext();
227 227

  
src/main/java/org/distorted/examples/effects3d/Effects3DSurfaceView.java
19 19

  
20 20
package org.distorted.examples.effects3d;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27
import android.view.MotionEvent;
......
33 35

  
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
35 37
   
36
  public Effects3DSurfaceView(Context c, AttributeSet attrs)
38
  public Effects3DSurfaceView(Context context, AttributeSet attrs)
37 39
    {
38
    super(c, attrs);
40
    super(context, attrs);
39 41
      
40 42
    if(!isInEditMode())
41 43
      {
42
      setEGLContextClientVersion(2);
44
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
45
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
46
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
47
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
43 48
      mRenderer = new Effects3DRenderer(this);
44 49
      setRenderer(mRenderer);
45 50
      }
src/main/java/org/distorted/examples/fbo/FBORenderer.java
42 42

  
43 43
import android.graphics.Bitmap;
44 44
import android.graphics.BitmapFactory;
45
import android.opengl.GLES20;
45
import android.opengl.GLES30;
46 46
import android.opengl.GLSurfaceView;
47 47

  
48 48
///////////////////////////////////////////////////////////////////////////////////////////////////
......
79 79
   
80 80
   public void onDrawFrame(GL10 glUnused)
81 81
      {
82
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
82
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
83 83
      mScreen.renderTo(mRoot,System.currentTimeMillis());
84 84
      }
85 85

  
......
113 113
    
114 114
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
115 115
      {
116
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
116
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
117 117

  
118 118
      InputStream is1 = mView.getContext().getResources().openRawResource(R.raw.monalisa);
119 119
      InputStream is2 = mView.getContext().getResources().openRawResource(R.raw.grid);
src/main/java/org/distorted/examples/fbo/FBOSurfaceView.java
19 19

  
20 20
package org.distorted.examples.fbo;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35
   
34
    public FBOSurfaceView(Context c, AttributeSet attrs)
36
    public FBOSurfaceView(Context context, AttributeSet attrs)
35 37
      {
36
      super(c, attrs);
38
      super(context, attrs);
37 39

  
38 40
      if(!isInEditMode())
39 41
        {
40
        setEGLContextClientVersion(2);
42
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
43
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
44
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
41 46
        mRenderer = new FBORenderer(this);
42 47
        setRenderer(mRenderer);
43 48
        }
src/main/java/org/distorted/examples/flag/FlagRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES20;
24
import android.opengl.GLES30;
25 25
import android.opengl.GLSurfaceView;
26 26

  
27 27
import org.distorted.examples.R;
......
142 142

  
143 143
    public void onDrawFrame(GL10 glUnused) 
144 144
      {
145
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
145
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
146 146
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
147 147
      }
148 148

  
......
178 178
    
179 179
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
180 180
      {
181
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
181
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
182 182

  
183 183
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.iceland);
184 184
      Bitmap bitmap;
src/main/java/org/distorted/examples/flag/FlagSurfaceView.java
19 19

  
20 20
package org.distorted.examples.flag;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27
import android.view.MotionEvent;
......
33 35
	
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
35 37
   
36
    public FlagSurfaceView(Context c, AttributeSet attrs)
38
    public FlagSurfaceView(Context context, AttributeSet attrs)
37 39
      {
38
      super(c,attrs);
40
      super(context,attrs);
39 41
    
40 42
      mX = -1;
41 43
      mY = -1;
42 44
      
43 45
      if(!isInEditMode())
44 46
        {
45
        setEGLContextClientVersion(2);
47
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
48
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
49
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
50
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
46 51
        mRenderer = new FlagRenderer(this);
47 52
        setRenderer(mRenderer);
48 53
        }
src/main/java/org/distorted/examples/girl/GirlRenderer.java
41 41

  
42 42
import android.graphics.Bitmap;
43 43
import android.graphics.BitmapFactory;
44
import android.opengl.GLES20;
44
import android.opengl.GLES30;
45 45
import android.opengl.GLSurfaceView;
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
153 153
   
154 154
   public void onDrawFrame(GL10 glUnused) 
155 155
      {
156
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
156
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
157 157
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
158 158
      }
159 159

  
......
187 187
    
188 188
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
189 189
      {
190
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
190
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
191 191

  
192 192
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl);
193 193
      Bitmap bitmap;
src/main/java/org/distorted/examples/girl/GirlSurfaceView.java
19 19

  
20 20
package org.distorted.examples.girl;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35
   
34
  public GirlSurfaceView(Context c, AttributeSet attrs) 
36
  public GirlSurfaceView(Context context, AttributeSet attrs)
35 37
      {
36
      super(c, attrs);
38
      super(context, attrs);
37 39

  
38 40
      if(!isInEditMode())
39 41
        {
40
        setEGLContextClientVersion(2);
42
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
43
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
44
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
41 46
        mRenderer = new GirlRenderer(this);
42 47
        setRenderer(mRenderer);
43 48
        }
src/main/java/org/distorted/examples/listener/ListenerRenderer.java
43 43

  
44 44
import android.graphics.Bitmap;
45 45
import android.graphics.BitmapFactory;
46
import android.opengl.GLES20;
46
import android.opengl.GLES30;
47 47
import android.opengl.GLSurfaceView;
48 48

  
49 49
///////////////////////////////////////////////////////////////////////////////////////////////////
......
105 105

  
106 106
    public void onDrawFrame(GL10 glUnused) 
107 107
      {
108
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
108
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
109 109
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
110 110
      }
111 111

  
......
139 139
    
140 140
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
141 141
      {
142
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
142
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
143 143

  
144 144
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.water);
145 145
      Bitmap bitmap;
src/main/java/org/distorted/examples/listener/ListenerSurfaceView.java
19 19

  
20 20
package org.distorted.examples.listener;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
......
31 33
    public ListenerSurfaceView(Context context) 
32 34
      {
33 35
      super(context);
34
      setEGLContextClientVersion(2);
36
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
37
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
38
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
39
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
35 40
      setRenderer(new ListenerRenderer(this));
36 41
      }
37 42
}
src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.java
19 19

  
20 20
package org.distorted.examples.matrix3d;
21 21

  
22
import android.opengl.GLES20;
22
import android.opengl.GLES30;
23 23
import android.opengl.GLSurfaceView;
24 24

  
25 25
import org.distorted.library.Distorted;
......
61 61

  
62 62
    public void onDrawFrame(GL10 glUnused)
63 63
      {
64
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
64
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
65 65
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
66 66
      }
67 67

  
......
93 93

  
94 94
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
95 95
      {
96
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
96
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
97 97

  
98 98
      Matrix3DActivity act = (Matrix3DActivity)mView.getContext();
99 99

  
src/main/java/org/distorted/examples/matrix3d/Matrix3DSurfaceView.java
19 19

  
20 20
package org.distorted.examples.matrix3d;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35
   
34
  public Matrix3DSurfaceView(Context c, AttributeSet attrs)
36
  public Matrix3DSurfaceView(Context context, AttributeSet attrs)
35 37
    {
36
    super(c, attrs);
38
    super(context, attrs);
37 39
      
38 40
    if(!isInEditMode())
39 41
      {
40
      setEGLContextClientVersion(2);
42
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
43
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
44
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
45
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
41 46
      mRenderer = new Matrix3DRenderer(this);
42 47
      setRenderer(mRenderer);
43 48
      }
src/main/java/org/distorted/examples/mirror/MirrorRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES20;
24
import android.opengl.GLES30;
25 25
import android.opengl.GLSurfaceView;
26 26

  
27 27
import org.distorted.examples.R;
......
108 108

  
109 109
   public void onDrawFrame(GL10 glUnused) 
110 110
      {
111
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
111
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
112 112

  
113 113
      long time = System.currentTimeMillis();
114 114

  
......
155 155
    
156 156
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
157 157
      {
158
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
158
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
159 159

  
160 160
      InputStream isM = mView.getContext().getResources().openRawResource(R.raw.mirror);
161 161
      InputStream isH = mView.getContext().getResources().openRawResource(R.raw.messi);
src/main/java/org/distorted/examples/mirror/MirrorSurfaceView.java
19 19

  
20 20
package org.distorted.examples.mirror;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26
import android.util.AttributeSet;
25 27

  
......
31 33

  
32 34
///////////////////////////////////////////////////////////////////////////////////////////////////
33 35

  
34
    public MirrorSurfaceView(Context c, AttributeSet attrs)
36
    public MirrorSurfaceView(Context context, AttributeSet attrs)
35 37
      {
36
      super(c, attrs);
38
      super(context, attrs);
37 39

  
38 40
      if(!isInEditMode())
39 41
        {
40
        setEGLContextClientVersion(2);
42
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
43
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
44
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
45
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
41 46
        mRenderer = new MirrorRenderer(this);
42 47
        setRenderer(mRenderer);
43 48
        }
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
38 38

  
39 39
import android.graphics.Bitmap;
40 40
import android.graphics.BitmapFactory;
41
import android.opengl.GLES20;
41
import android.opengl.GLES30;
42 42
import android.opengl.GLSurfaceView;
43 43

  
44 44
///////////////////////////////////////////////////////////////////////////////////////////////////
......
81 81
   
82 82
    public void onDrawFrame(GL10 glUnused) 
83 83
      {
84
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
84
      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
85 85
      mScreen.renderTo(mTexture, mMesh, mEffects, System.currentTimeMillis() );
86 86
      }
87 87

  
......
113 113
    
114 114
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
115 115
      {
116
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
116
      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
117 117

  
118 118
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.monalisa);
119 119
      Bitmap bitmap;
src/main/java/org/distorted/examples/monalisa/MonaLisaSurfaceView.java
19 19

  
20 20
package org.distorted.examples.monalisa;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.opengl.GLSurfaceView;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
......
31 33
    public MonaLisaSurfaceView(Context context) 
32 34
      {
33 35
      super(context);
34
      setEGLContextClientVersion(2);
36
      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
37
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
38
      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
39
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
35 40
      setRenderer(new MonaLisaRenderer(this));
36 41
      }
37 42
}
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java
26 26
import android.graphics.Canvas;
27 27
import android.graphics.Paint;
28 28
import android.graphics.Paint.Style;
29
import android.opengl.GLES20;
29
import android.opengl.GLES30;
30 30
import android.opengl.GLSurfaceView;
31 31

  
32 32
import org.distorted.library.DistortedFramebuffer;
......
141 141
   
142 142
   public void onDrawFrame(GL10 glUnused)
143 143
     {   
144
     GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);               
144
     GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT | GLES30.GL_DEPTH_BUFFER_BIT);               
145 145
       
146 146
     long time = System.currentTimeMillis();
147 147
      
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
19 19

  
20 20
package org.distorted.examples.movingeffects;
21 21

  
22
import android.app.ActivityManager;
22 23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
23 25
import android.graphics.Canvas;
24 26
import android.graphics.Paint;
25 27
import android.graphics.Paint.Style;
......
68 70

  
69 71
///////////////////////////////////////////////////////////////////////////////////////////////////
70 72
    
71
    public MovingEffectsSurfaceView(Context c, AttributeSet attrs) 
73
    public MovingEffectsSurfaceView(Context context, AttributeSet attrs)
72 74
      {
73
      super(c, attrs);
75
      super(context, attrs);
74 76

  
75 77
      mCurrEffect=EFFECT_POINTS;
76 78
      mPaint = new Paint();
......
86 88
        {
87 89
        setFocusable(true);
88 90
        setFocusableInTouchMode(true);
89
        setEGLContextClientVersion(2);
91
        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
92
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
93
        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
94
        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
90 95
        setRenderer(mRenderer);
91 96
        }
92 97
      }
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
40 40

  
41 41
import android.graphics.Bitmap;
42 42
import android.graphics.BitmapFactory;
43
import android.opengl.GLES20;
43
import android.opengl.GLES30;
44 44
import android.opengl.GLSurfaceView;
45 45

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff