I am trying to implement a openGL ES 2.0 game using NDK in C++ . My test device was ASUS Zenphone 5 I am pretty sure it supports openGL ES 2.0 as it can run games based on openGL ES 2 from play store very smoothly and also the helloGl2 sample in androind NDK.
When I called glCreateShader
log cat gave an error "called unimplemented api" by googling a bit I found out it was because the app was using openGL ES 1 context by default.
So I modified the EGL context creation code from:
context = eglCreateContext(display, config, NULL, NULL);
to
EGLint contextAttrs[] = {
EGL_CONTEXT_CLIENT_VERSION,2,EGL_NONE
};
context = eglCreateContext(display, config, NULL, contextAttrs);
Now this gave a different error
E/libEGL(12670): validate_display:257 error 3008 (EGL_BAD_DISPLAY)
However when I tested it on a galaxy s3 (GT-I9100) there was no BAD DISPLAY ERROR , but the app crashed on calling glCreateShader with fatal signal SIGSEV
What is going on here?
If you are creating an ES 2 context, you also need to include EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT
in the attributes for the EGL config, it's not enough to add EGL_CONTEXT_CLIENT_VERSION, 2
to the context attributes.
Also, make sure you are linking to libGLESv2.so ( -lGLESv2
in LOCAL_LDLIBS
), and make sure you aren't linking in libGLESv1_CM.so by accident. (Using them both in the same process requires a bit of extra trickery.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.