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; }
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:
The settings in manifest XML file:
GLES version detection in CPP file:
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.
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