【问】

I'm trying to make an NDK based OpenGL application. At some point in my code, I want to check the OpenGL version available on the device.

I'm using the following code :

const char *version = (const char *) glGetString(GL_VERSION);

if (strstr(version, "OpenGL ES 2.")) {

// do something

} else {

__android_log_print(ANDROID_LOG_ERROR, "NativeGL", "Open GL 2 not available (%s)", version=;

}

THe problem is that the version string is always equals to "OpenGL ES-CM 1.1".

I'm testing on both a Moto G (Android 4.4.4) and Samsung Galaxy Nexus (Android 4.3), both of which are OpenGL ES 2.0 compliant (the moto G is also OpenGL ES 3.0 compliant).

I tried to force the EGL_CONTEXT_CLIENT_VERSION when I initialise my display, but then eglChooseConfig returns 0 configurations. And when I test the context client version value in the default configuration, it's always 0 :

const EGLint attrib_list[] = {

EGL_BLUE_SIZE, 8,

EGL_GREEN_SIZE, 8,

EGL_RED_SIZE, 8,

EGL_NONE

};

 

// get the number of configs matching the attrib_list

EGLint num_configs;

eglChooseConfig(display, attrib_list, NULL, 0, &num_configs);

LOG_D(TAG, " • %d EGL configurations found", num_configs);

 

// find matching configurations

EGLConfig configs[num_configs];

EGLint client_version = 0, depth_size = 0, stencil_size = 0, surface_type = 0;

eglChooseConfig(display, requirements, configs, num_configs, &num_configs);

for(int i = 0; i < num_configs; ++i){

 

eglGetConfigAttrib(display, configs[i], EGL_CONTEXT_CLIENT_VERSION, &client_version);

 

 

LOG_D(TAG, " client version %d = 0x%08x", i, client_version);

 

}

 

// Update the window format from the configuration

EGLint format;

eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);

ANativeWindow_setBuffersGeometry(window, 0, 0, format);

 

// create the surface and context

EGLSurface surface = eglCreateWindowSurface(display, config, window, NULL);

EGLContext context = eglCreateContext(display, config, NULL, NULL);

I'm linking against the Open GL ES 2.0 library : here's the excerpt from my Android.mk

LOCAL_LDLIBS := -landroid -llog -lEGL -lGLESv2

 

【答】

What version you get from glGetString(GL_VERSION) depends on which library you've linked the code against, either libGLESv1_CM.so or libGLESv2.so. Similarly for all the other common GL functions. This means that in practice, you need to build two separate .so files for your GL ES 1 and 2 versions of your rendering, and only load the right one once you know which one of them you can use (or load the function pointers dynamically). (This apparently is different when having compatibility between GL ES 2 and 3, where you can check using glGetString(GL_VERSION).)

You didn't say where you tried using EGL_CONTEXT_CLIENT_VERSION - it should be used in the parameter array to eglCreateContext (which you only call once you actually have chosen a config). The attribute array given to eglChooseConfig should have the pair EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT to get a suitable config.

 

 

来自:https://stackoverflow.com/questions/25843368/glgetstringgl-version-returns-opengl-es-cm-1-1-but-my-phone-supports-opengl

glGetString(GL_VERSION) returns “OpenGL ES-CM 1.1” but my phone supports OpenGL 2的更多相关文章

  1. OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)

    一. OpenGL的基本概念 OpenGL 的结构可以从逻辑上划分为下面 3 个部分: 图元(Primitives) 缓冲区(Buffers) 光栅化(Rasterize) 图元(Primitives ...

  2. 笔谈OpenGL ES(二)

    昨晚回家也看了OpenGL ES 2.0 iOS教程的第一篇,对于其中涉及的一些基本知识罗列下,虽然自己做iOS开发一年多了,但是对于一些细节没有注意,真正的把自己当成“应用”工程师了 ,不仅要会用, ...

  3. 【AR实验室】OpenGL ES绘制相机(OpenGL ES 1.0版本)

    0x00 - 前言 之前做一些移动端的AR应用以及目前看到的一些AR应用,基本上都是这样一个套路:手机背景显示现实场景,然后在该背景上进行图形学绘制.至于图形学绘制时,相机外参的解算使用的是V-SLA ...

  4. Android OpenGL ES 开发教程 从入门到精通

    感谢,摘自:http://blog.csdn.net/mapdigit/article/details/7526556 Android OpenGL ES 简明开发教程 Android OpenGL ...

  5. OpenGL 和OpenGL ES简介

    OpenGL的全称是Open  Graphics  Library,即开放的图形库接口,它定义了一个跨编程语言.跨平台的编程接口的规范,它主要用于三维图形(实际上二维图形也可以)变成.OpenGL的前 ...

  6. Beginning OpenGL ES 2.0 with GLKit Part 1

    Update 10/24/12: If you’d like a new version of this tutorial fully updated for iOS 6 and Xcode 4.5, ...

  7. OpenGL ES着色器语言之变量和数据类型(一)(官方文档第四章)和varying,uniform,attribute修饰范围

    OpenGL ES着色器语言之变量和数据类型(一)(官方文档第四章)   所有变量和函数在使用前必须声明.变量和函数名是标识符. 没有默认类型,所有变量和函数声明必须包含一个声明类型以及可选的修饰符. ...

  8. EGL接口介绍-----Android OpenGL ES底层开发

    引自:http://www.cnitblog.com/zouzheng/archive/2011/05/30/74326.html EGL 是 OpenGL ES 和底层 Native 平台视窗系统之 ...

  9. Android OpenGL ES(十四)gl10方法解析

    Android 支持 OpenGL 列表 1.GL 2.GL 10 3.GL 10 EXT 4.GL 11 5.GL 11 EXT 6.GL 11 ExtensionPack 我们将使用 GL10 这 ...

随机推荐

  1. 使用ptrace向已运行进程中注入.so并执行相关函数(转)

    1. 简介 使用ptrace向已运行进程中注入.so并执行相关函数,其中的“注入”二字的真正含义为:此.so被link到已运行进程(以下简称为:目标进程)空间中,从而.so中的函数在目标进程空间中有对 ...

  2. oracle 11g wm_concat 、 listagg 函数的使用(合并数据)

    方法一 wn_concat() 函数 1.把以下图中Name一样的数据合并为一条,而且NO的值要这样显示如 C.1,C.2 2.实现这种效果的操作如下,先把Name的值进行分组(group by),再 ...

  3. golang-bcc-bpf-function-tracing

    http://www.brendangregg.com/blog/2017-01-31/golang-bcc-bpf-function-tracing.html

  4. iOS十进制切割格式转换

    //@"123456789" 转换后 @"123,456,789" @interface NSString (num) - (NSString *)money; ...

  5. “CMD /C”的特殊应用

    命令行下似乎有数不尽的秘密,稍微挖掘一下就会有意外惊喜.今天跟各位朋友分享一下“CMD /C”的特殊应用,希望能对大家有所帮助.在cmd的帮助文件里,它是这样介绍/c参数的: “CMD [/C str ...

  6. lodash用法系列(5),链式

    Lodash用来操作对象和集合,比Underscore拥有更多的功能和更好的性能. 官网:https://lodash.com/引用:<script src="//cdnjs.clou ...

  7. Android 程序目录介绍

    还是回到 Eclipse 中,首先展开 HelloWorld 项目,你会看到如图 1.17 所示的目录结构. 图   1.17 一开始看到这么多陌生的东西,你一定会感到有点头晕吧.别担心,我现在就对上 ...

  8. Java Dictionary 类存储键值

    字典(Dictionary) 字典(Dictionary) 类是一个抽象类,它定义了键映射到值的数据结构. 当你想要通过特定的键而不是整数索引来访问数据的时候,这时候应该使用Dictionary. 当 ...

  9. 在xcode5下设置两个viewController跳转——关键是禁用arc

    1.禁用arc 2.然后使用如下代码: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( ...

  10. 详细注释!二维码条码扫描源码,使用Zxing core2.3

    from:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=325529&page=1 现如今很多项目中都会应用到条码扫描解 ...