Reputation: 4838
I'm working on Android with OpenGL. I known how to use GLSurfaceView
and its custom derivate classes to create OpenGL ES 2.0 context with method of GLSurfaceView
:
setEGLContextClientVersion(2);
and OpenGL ES 3.0 context:
setEGLContextClientVersion(3);
How can i create a context for OpenGL ES 3.1?
Upvotes: 8
Views: 6079
Reputation: 54642
You can't explicitly request 3.1 when you create the context. Based on my understanding, 3.1 is not handled as a context type separate from 3.0. Essentially, a context supporting 3.1 is just a 3.0 context that also supports the additional 3.1 features.
This means that you can still use:
setEGLContextClientVersion(3);
If you want to check/verify what version is supported by the context, you can query it once you have the context up and running:
int[] vers = new int[2];
GLES30.glGetIntegerv(GLES30.GL_MAJOR_VERSION, vers, 0);
GLES30.glGetIntegerv(GLES30.GL_MINOR_VERSION, vers, 1);
if (vers[0] > 3 || (vers[0] == 3 && vers[1] >= 1)) {
// We have at least ES 3.1.
}
The latest version of EGL, which is 1.5 [*], actually does have context creation attributes that allow specifying both a major and minor version (attributes EGL_CONTEXT_MAJOR_VERSION
and EGL_CONTEXT_MINOR_VERSION
). Versions up to and including 1.4 only have EGL_CONTEXT_CLIENT_VERSION
, so they have no mechanism to specify the minor version when creating a context.
The latest released version of Android, which is 5.1.1 [*], still only supports EGL 1.4. So it's not only a question of GLSurfaceView
not providing an interface. The lower native layers do not support specifying a minor version either. So adding 3.1 support to 3.0 contexts is really the only option.
[*] At the time this answer was written.
Upvotes: 8