How to set 3.1 opengl version in jme-android?

Hello, i want to know how can I set OPENGL version from anything to 3.1 in jme-android.
Thanks in advance.


Not sure if it is possible, I think it automatically detects the OpenGL ES version based on device capability. So for example, if the device supports OpenGL ES 3.1 it will add it to caps.

Note android uses OpenGL ES which is not the same as desktop OpenGL.

1 Like

Btw, for general knowledge, you can also retrieve the current gles version from here (it is new in JmeSurfaceView):

1 Like

And how to enable and disable vsync?

But i want it to force 3.1 version!

While you can do what you want, but it’s not clean in any way, you need to inject this before jme runs GlSurfaceView#setRenderer and after jme sets up your opengl context:

There is another better solution tho, you can do this from your Android application, for example:

If the opengles is less than 3.0 (which is settled by jme when the game starts), then terminate (keep in mind forcing a particular high version of opengl won’t work on old devices), this ensures that your application only runs when the device supports opengles 3:

protected void onCreate(...) {
    ConfigurationInfo configurationInfo = ((ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo();
    float glversion = Float.parseFloat(configurationInfo.getGlEsVersion());
    if (glversion < 3.0f) {
             /* display a dialog of failure and an exit prompt */
            exitPrompt(getContext(), glversion);

private void exitPrompt(final Context context, final float minGlVersion) {
    final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle("Minimum GLES version is " + minGlVersion);
    alertDialog.setMessage("Your device GPU doesn't support OpenGLES-3, terminating now");
    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_NEGATIVE:

but if you set the opengles version manually before the harness activity, it will get overridden by jme to the best version…

EDIT: I added a full code; please don’t copy, if you don’t understand, better ask.

1 Like

But how jme will know which version to use?

And AndroidManifest i have forced gles version to 3.1 so it will install only if user has 3.1 version.

AndroidManifest is not reliable these days on some android APIs (as BroadCasts, Providers and Intents), you have to deal with this programmatically to be on the safe side.

1 Like

The Android API provides a ConfigurationInfo class that provides these information, as shown in the above example.

If you mean which version to use initially during the setup, it tests the highest possible version and check if it works, or fall back to a lower version if the higher doesnot work.

Means that jme automatically try the highest possible gl version but if the highest version fails then it uses the lower version.

1 Like

Yeah, that’s true.
Even I have some problems with my privious app.

1 Like