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