Revision 41a81a14
Added by Leszek Koltunski over 7 years ago
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 |
} |
Also available in: Unified diff
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!)