Question

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;
}
Was it helpful?

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.

OTHER TIPS

I am using nexus 7 (2012) and that's probably my problem ( although I would think eglCreateContext would fail with EGL_CONTEXT_CLIENT_VERSION, 3 )

Here is a correct way of initializing OpenGL ES 3.0 context in Android - create OpenGL ES 2.0 context and check whether GL version of created context is 3.0. Yes you don't need to explicitly specify EGL_CONTEXT_CLIENT_VERSION 3 - GLES 3.0 is fully backwards compatible w/ 2.0 that's why Android creates ES 3.0 context if hardware supports it. If hardware is not capable of running ES 3.0 you will get usual ES 2.0 which is 100% available on any device running Android 2.2 and up.

In our apps I'm doing it exactly this way and it works (I use Java, though).

This was explained by no one else but Romain Guy on the first days of Android 4.3 release: https://plus.google.com/u/0/+RomainGuy/posts/iJmTjpUfR5E - and I trust this guy.

P.S. Speaking of Nexus 7 1st gen - yes it's GPU (Tegra3) doesn't support ES 3.0, as well as Tegra4 - only next-gen Tegra5 (Tegra K1) supports it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top