带有 OpenGL ES 3.1 上下文的 GLSurfaceView [英] GLSurfaceView with OpenGL ES 3.1 context

查看:213
本文介绍了带有 OpenGL ES 3.1 上下文的 GLSurfaceView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 OpenGL 开发 Android.我知道如何使用 GLSurfaceView 及其自定义派生类通过 GLSurfaceView 的方法创建 OpenGL ES 2.0 上下文:

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); 

和 OpenGL ES 3.0 上下文:

and OpenGL ES 3.0 context:

setEGLContextClientVersion(3); 

如何为 OpenGL ES 3.1 创建上下文?

How can i create a context for OpenGL ES 3.1?

推荐答案

您不能在创建上下文时显式请求 3.1.根据我的理解,3.1 不是作为独立于 3.0 的上下文类型处理的.本质上,支持 3.1 的上下文只是一个 3.0 上下文,它也支持 3.1 的附加功能.

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

背景

最新版本的 EGL,即 1.5 [*],实际上确实具有允许指定主要和次要版本的上下文创建属性(属性 EGL_CONTEXT_MAJOR_VERSIONEGL_CONTEXT_MINOR_VERSION).1.4 及以下版本只有 EGL_CONTEXT_CLIENT_VERSION,因此它们没有机制在创建上下文时指定次要版本.

Background

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.

Android 最新发布的版本是 5.1.1 [*],仍然只支持 EGL 1.4.所以这不仅仅是 GLSurfaceView 不提供接口的问题.较低的原生层也不支持指定次要版本.因此,在 3.0 上下文中添加 3.1 支持确实是唯一的选择.

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.

这篇关于带有 OpenGL ES 3.1 上下文的 GLSurfaceView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆