Search code examples
androidopengl-eseglopengl-es-3.0

glBindBuffer with GL_PIXEL_PACK_BUFFER returns enum error code


I am trying to do :

glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo_id);

in android 4.3 and I am getting 'enum error code', although the docs say I can use GL_PIXEL_PACK_BUFFER.

Perhaps I am not using 'OpenGL ES 3.0' ? What do I need to to to force v3 usage ?

OpenGL context:

EGLint numConfigs = 0;
EGLint configAttribs[] = {
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
    EGL_RECORDABLE_ANDROID, 1,
    EGL_RED_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_BLUE_SIZE, 8,
    EGL_ALPHA_SIZE, 8,
    EGL_NONE
};

result = eglChooseConfig(mEglDisplay, configAttribs, &mEglConfig, 1,
        &numConfigs);
if (result != EGL_TRUE) {
    fprintf(stderr,"eglChooseConfig error: %#x", eglGetError());
    return UNKNOWN_ERROR;
}

EGLint contextAttribs[] = {
    EGL_CONTEXT_CLIENT_VERSION, 3,
    EGL_NONE
};
mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT,
        contextAttribs);
if (mEglContext == EGL_NO_CONTEXT) {
    fprintf(stderr,"eglCreateContext error: %#x", eglGetError());
    return UNKNOWN_ERROR;
}

Solution

  • So yes, having Android 4.3 does not guarantee OpenGL ES 3.0, it merely enables it for compatible devices. The device needs a OpenGL ES 3.0 -enabled GPU. Nexus 7 (2012) has the NVIDIA Tegra 3 SoC which only supports OpenGL ES 2.0. You can't "force" this device to use a 3.0 context.

    As for eglCreateContext not failing, I'm not sure. Looking at the specification quickly it seems that behavior for other values besides 2 and 1 is not really defined.