Is there a way to check if Android device supports openGL ES 2.0?

后端 未结 7 1048
轻奢々
轻奢々 2020-12-02 23:16

I need to check dynamically if the used device supports openGL ES 2.0. How can i do that?

7条回答
  •  囚心锁ツ
    2020-12-02 23:49

    This code working Fine..

         // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager = ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
        final ConfigurationInfo configurationInfo = activityManager
                .getDeviceConfigurationInfo();
        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
    
        if (supportsEs2) {
            Log.i("JO", "configurationInfo.reqGlEsVersion:"
                    + configurationInfo.reqGlEsVersion + "supportsEs2:"
                    + supportsEs2);
            // Request an OpenGL ES 2.0 compatible context.
            myGlsurfaceView.setEGLContextClientVersion(2);
    
            final DisplayMetrics displayMetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    
            // Set the renderer to our demo renderer, defined below.
            myRenderer = new MyRenderer(this, myGlsurfaceView);
                } else {
            // This is where you could create an OpenGL ES 1.x compatible
            // renderer if you wanted to support both ES 1 and ES 2.
            return;
        }
    

提交回复
热议问题