Java – glsurfaceview using OpenGL es 3.1 context

I'm working with Android using OpenGL. I know how to use glsurfaceview and its custom derived classes to create an OpenGL es 2.0 context using the glsurfaceview method:

setEGLContextClientVersion(2); 

And OpenGL es 3.0 context:

setEGLContextClientVersion(3); 

How do I create a context for OpenGL es 3.1?

resolvent:

When creating a context, you cannot explicitly request 3.1. According to my understanding, 3.1 is not treated as a context type separate from 3.0. In essence, the context supporting 3.1 is only a 3.0 context, and also supports additional 3.1 functions

This means that you can still use:

setEGLContextClientVersion(3);

If you want to check / verify the version supported by the context, you can query it after the context runs:

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.
}

background

The latest version of EGL (1.5 [*]) actually has a context creation attribute that allows specifying major and minor versions (attributes egl_context_major_version and egl_context_minor_version). Versions before 1.4 only contain EGL_ CONTEXT_ CLIENT_ Version, so they have no mechanism to specify a minor version when creating a context

The latest Android version, 5.1.1 [*], still only supports EGL 1.4. Therefore, it is not only the problem that glsurfaceview does not provide an interface. The lower native layer does not support specifying minor versions. Therefore, adding 3.1 support to the 3.0 context is the only option

[*] when writing this answer

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>