Revision 41a81a14
Added by Leszek Koltunski over 7 years ago
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 |
} |
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!)