This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why my Android 4.3 Emulator could not support the OpenGL ES 3.0

The SDK and ADT have been updated in my IDE, and I create an Android 4.3 Emulator successfully. Then I run the OpenGL ES 3.0 demo code on the Emulator , but the Logcat output "OpenGL ES3.0 not supported on device...", The reason seems to be the OpenGL ES 3.0 context could not be created successfully. The demo comes from  book " The OpenGL ES 3.0 Programming guide". Settings have been done in the XML file.

     My PC : windows 7, 4GB RAM, Intel Core i3, GPU NVIDIA Geforce G7X550 Ti.  The information of the Emulator is Android 4.3.

     Code of creating  OpenGL ES3.0 context:

public class SimpleTexture2D extends Activity
{


   private final int CONTEXT_CLIENT_VERSION = 3;


   @Override
   protected void onCreate ( Bundle savedInstanceState )
   {
      super.onCreate ( savedInstanceState );
      mGLSurfaceView = new GLSurfaceView ( this );


      if ( detectOpenGLES30() )
      {
         // Tell the surface view we want to create an OpenGL ES 3.0-compatible
         // context, and set an OpenGL ES 3.0-compatible renderer.
         mGLSurfaceView.setEGLContextClientVersion ( CONTEXT_CLIENT_VERSION );
         mGLSurfaceView.setRenderer ( new SimpleTexture2DRenderer ( this ) );
      }
      else
      {
         Log.e ( "SimpleTexture2D", "OpenGL ES 3.0 not supported on device.  Exiting..." );
         finish();
      }


      setContentView ( mGLSurfaceView );
   }


   private boolean detectOpenGLES30()
   {
      ActivityManager am =
         ( ActivityManager ) getSystemService ( Context.ACTIVITY_SERVICE );
      ConfigurationInfo info = am.getDeviceConfigurationInfo();
      return ( info.reqGlEsVersion >= 0x30000 );
   }


   @Override
   protected void onResume()
   {
      // Ideally a game should implement onResume() and onPause()
      // to take appropriate action when the activity looses focus
      super.onResume();
      mGLSurfaceView.onResume();
   }


   @Override
   protected void onPause()
   {
      // Ideally a game should implement onResume() and onPause()
      // to take appropriate action when the activity looses focus
      super.onPause();
      mGLSurfaceView.onPause();
   }


   private GLSurfaceView mGLSurfaceView;
}
Parents Reply Children
  • Hi Chris

    Thank you very much for your reply. I have selected Use Host GPU, and SDK version is 18, my AVD support GLES 2. I run another demo from google NDK-r9d samples, gles3jni, which can run on my emulator. The demo build GLES context in JAVA, then detect the GLES version and choose GLES 2.0 or GLES 3.0  to render in CPP file. While GLES 2.0 was choosed, demo runs by GLES 2.0. Is that means GLES 3.0 context was not build?

    Thank you very much, best wishes

    Autman.

  • Having a quick look at the gles3jni sample, it has 2 possible targets, SDK 11 and 18, which will require GLES2 and 3 respectively, were you definitely building and running the GLES3/SDK18 version? I'm not convinced that the emulator AVD will support GLES3, so need to confirm you're running the GLES3 apk not the GLES2 one.

    Thanks,

    Chris

  • Hi Chris

    Sorry for my late reply. I have check the demo again, the SDK 18 was selected, I build and run the GLES3/SDK18 version. The apk is the GLES3 one.

    Thank you very much. Best wishes.

    Autman

  • Had a thought, I think ActivityManager::getDeviceConfigurationInfo() just returns the preferences listed by the application in the manifest, rather than the actual device capabilities. I've got a feeling you're missing the following line from your manifest?

    <uses-feature android:glEsVersion="0x00030000"/>

    This should change the value of info.reqGlEsVersion. I'm not sure what the correct way of querying device capabilities is however, but should be something in the Android reference.

    Hope this helps,

    Chris

    EDIT: Useful links:

    ConfigurationInfo | Android Developers

  • Hi, Chris:

              Thank you. There is no missing about the glEsVersion in the manifest, XML file. Some one also encounter the problem , their emulator could not support OpenGL ES 3.0 on the platform 18 or above, even not OpenGL ES2.0 on the platform under 18. Mine could support the OpenGL ES 2.0 on platforms under 18, but OpenGL ES 3.0 could not be detected on the platform 18 or above.

    The Code build OPenGL ES context in Java:

    1.     public GLES3JNIView(Context context) {
    2.         super(context);
    3.         // Pick an EGLConfig with RGB8 color, 16-bit depth, no stencil,
    4.         // supporting OpenGL ES 2.0 or later backwards-compatible versions.
    5.         setEGLConfigChooser(8, 8, 8, 0, 16, 0);
    6.         setEGLContextClientVersion(2);//This should be 3???
    7.         setRenderer(new Renderer());
    8.     }

    The settings in manifest XML file:

    1.     </application>
    2.     <uses-feature android:glEsVersion="0x00030000"/>
    3.     <uses-sdk android:minSdkVersion="18"/>

    GLES version detection in CPP file:

    1.     printGlString("Version", GL_VERSION);
    2.     printGlString("Vendor", GL_VENDOR);
    3.     printGlString("Renderer", GL_RENDERER);
    4.     printGlString("Extensions", GL_EXTENSIONS);
    5.    
    6.     const char* versionStr = (const char*)glGetString(GL_VERSION);
    7.     if (strstr(versionStr, "OpenGL ES 3.") && gl3stubInit()) {
    8.         g_renderer = createES3Renderer();
    9.         ALOGE(" OpenGL ES version is 3.0");
    10.     } else if (strstr(versionStr, "OpenGL ES 2.")) {
    11.         g_renderer = createES2Renderer();
    12.         ALOGE(" OpenGL ES version is 2.0");
    13.     } else {
    14.         ALOGE("Unsupported OpenGL ES version");
    15.     }

    The OpenGL ES context is little difference comparing with mali's demo, however they both build OpenGL ES2.0 context in JAVA, The OPenGL ES 3.0 base on OPenGL ES 2.0 , is it?

    Can you leave your email address, I can send message to you, mine is 504957821@qq.com, from China, Wuhan

    Thank you very much, Best wishes.

    Autman

  • Hi Autman,

    Feel free to email any mali specific queries to malidevelopers@arm.com, but this isn't really Mali related.

    setEGLContextClientVersion(2);//This should be 3???

    Maybe, I'd try it and see what happens... I would have thought that you would explicitly ask for a GLES3 context if you want one, although I can imagine implementations of GLES3 would just give you a GLES3 context even if you asked for GLES2, or they would give you a GLES2 context and explicitly ignore calls to core GLES3 functions in a GLES2 context (and report major version as 2!! could be the case here), one or the other. I'm not familiar with what the emulator does, although from reading around I'm surprised even GLES2 works for you!

    From my reading of the spec, GL_VERSION has to contain "OpenGL ES N.M vendor-specific information", but I can't say for sure if the emulator implementation follows this spec, maybe they always return ES 2.0? What does glGetIntegerv(GL_MAJOR_VERSION) return? I'm also still confused that by putting <uses-feature android:glEsVersion="0x00030000"/> in your manifest you could get anything other than 0x30000 from info.reqGlEsVersion, as from reading the description of the ConfigurationInfo class, it only contains application preferences declared in the manifest <uses-feature> and <uses-configuration> tags, NOT actual device capabilities. Your DetectOpenGLES30 function therefore seems unnecessary, as all it's doing is checking what value you put in the manifest. Am I missing something? Maybe the ConfigurationInfo reference is badly written and it's actually more general, and calling ActivityManager::getDeviceConfigurationInfo() really does return device capabilities and not application preferences...

    Bottom line, if you can't get it to give you a GLES 3 context it's very likely because it doesn't support it, maybe this is written down in the release notes for the emulator? I'd recommend trying your app out on a real GLES3 capable device instead

    Hope this helps,

    Chris