All functions in the question are supported from OpenGL ES 2.0.
glCreateProgram()
glShaderSource()
glCompileShader()
EGL_CONTEXT_CLIENT_VERSION, 2
is enough for clearing "called unimplemented opengl es api" errors. So, I think the default version of ES on Nexus5 is less than 2 and it's the cause of this problem.
const EGLint attribs2[] =
{
EGL_CONTEXT_CLIENT_VERSION, 3, // ES 3.x
// EGL_CONTEXT_CLIENT_VERSION, 2, // if you want to use ES 2.x
EGL_NONE
};
context = eglCreateContext(displayHandle, config, EGL_NO_CONTEXT, attribs2);
Refs: glCreateProgram glShaderSource glCompileShader
With EGL_RENDERABLE_TYPE
, we have EGL_OPENGL_ES3_BIT_KHR
, which requires EGL 1.4.
EGL_OPENGL_ES3_BIT_KHR
is defined in EGL/eglext.h.
Include EGL/eglext.h
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES3/gl3.h>
and pass EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR
to eglChooseConfig()
const EGLint attribs1[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
//EGL_ALPHA_SIZE, 8,
//EGL_DEPTH_SIZE, 24, // if you want
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, // ES 3.x
EGL_NONE
};
GLES3/gl3platform.h is included by GLES3/gl3.h. GLES3/gl3.h contains most part of definitions in GLES2/gl2.h.
Ref: EGL_KHR_create_context
And link library depends on which ES version you want.
-lGLESv3
NB1: we can omit EGL_RENDERABLE_TYPE
attribute for eglChooseConfig()
EGL_RENDERABLE_TYPE
a bitmask indicating which types of client API contexts the frame
buffer configuration must support creating with eglCreateContext
...
The default value is EGL_OPENGL_ES_BIT.
EGL_OPENGL_ES_BIT
Config supports creating OpenGL ES 1.0 and/or 1.1 contexts.
Sort rules of configurations which are returned by eglChooseConfig()
.
EGLConfigs are not sorted with respect to the attributes ...
EGL_CONFORMANT, ... EGL_RENDERABLE_TYPE
So, I think having separate configurations depend on ES versions is rare but, eglChooseConfig()
may return a configuration which supports ES 1.0/1.1 as a first one.
Ref: eglChooseConfig
From eglCreateContext()
footnote
The requested attributes may not be able to be satisfied, but context
creation may still succeed.
Ref: eglCreateContext
NB2:
Creating ES 2.x context does not mean we can use it for ES 3.x.
I think device manufacturers don't want to implement EGL and ES version dependent functions, so eglCreateContext()
with EGL_CONTEXT_CLIENT_VERSION, 2
may return a context which can be used with ES 3.x but it depends on fortune.
Not always but libGLESv3 is just a symbolic link of libGLESv2, on some devices, with some Android versions. It's linked as a temporal bug fix, in old days, and that brought us many version related confusions.
If source cord contains ES 3.x functions, and linked with libGLESv2, linker will complain about undefined references these days.