简体   繁体   English

在 Android (NDK) 上设置 OpenGL ES 版本

[英]Set OpenGL ES version on Android (NDK)

I'm following these docs and trying to set OpenGL version to 1.1.我正在关注这些文档并尝试将 OpenGL 版本设置为 1.1。 But when I call glGetString(GL_VERSION) in my C code it always returns me但是当我在我的 C 代码中调用glGetString(GL_VERSION)时,它总是返回我

OpenGL ES-CM 1.0 OpenGL ES-CM 1.0

I believe I should specify version when I create context (or surface) but i can't find any API for this.我相信我应该在创建上下文(或表面)时指定版本,但我找不到任何 API。

I'm also getting such kind of errors:我也遇到了这样的错误:

08-09 13:47:13.642: ERROR/libEGL(567): called unimplemented OpenGL ES API 08-09 13:47:13.642: 错误/libEGL(567): 调用未实现的 OpenGL ES API

which also proves that OpenGL ES 1.0 is used instead of 1.1.这也证明了使用 OpenGL ES 1.0 而不是 1.1。

Edit: I should note that on device everything is OK.编辑:我应该注意,在设备上一切正常。 The problem exists only on emulator (tested on platforms 2.2 and 2.3.3)该问题仅存在于模拟器上(在平台 2.2 和 2.3.3 上测试)

Edit2: tested on HTC Wildfire with Android 2.2.1 and it also shows me OpenGL version 1.0 Edit2:在 HTC Wildfire 上使用 Android 2.2.1 进行测试,它还向我展示了 OpenGL 1.0 版

The emulator only implements 1.0, so that's to be expected.模拟器只实现了 1.0,所以这是意料之中的。 You end up getting whichever version the hardware (or emulator) supports.您最终会获得硬件(或仿真器)支持的任何版本。

In the manifest you only specify what version of GLES your app requires.在清单中,您只需指定您的应用所需的 GLES 版本。 From the manifest guide:从清单指南:

Declared elements are informational only, meaning that the Android system itself does not check for matching feature support on the device before installing an application.声明的元素仅供参考,这意味着 Android 系统本身在安装应用程序之前不会检查设备上的匹配功能支持。

I should note that the emulator does implement most 1.1 features such as VBO support, so you should be ok to test your application on it anyway by making some small changes.我应该注意到,模拟器确实实现了大多数 1.1 功能,例如 VBO 支持,所以你应该可以通过做一些小的改变来测试你的应用程序。

You should specify version when you create context,您应该在创建上下文时指定版本,
And in fact, there is a way to do that:事实上,有一种方法可以做到这一点:

const EGLint attribList[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
context = eglCreateContext(eglDisplay, config, EGL_NO_CONTEXT, attribList);

Take care of the attribList , this is the parameter you specify OpenGL ES version in.注意attribList ,这是您指定 OpenGL ES 版本的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM