Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Native NDK OpenGL ES: unimplemented API

I am working to implement an OpenGL ES 2.0 fully in C++ for Android.

Currently our program runs without JNI or any java class in the project, using instead only NativeActivity.

Focusing on the application rendering part itself, we got a simple method:

renderWorld()
{   GLfloat vVertices[] = {  0.0f,  0.5f, 0.0f,
                            -0.5f, -0.5f, 0.0f,
                             0.5f, -0.5f, 0.0f };
    glClear ( GL_COLOR_BUFFER_BIT );

    glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices );
    glEnableVertexAttribArray ( 0 );

    glDrawArrays (GL_TRIANGLES, 0, 3 );
}

In Android.mk was included:

LOCAL_LDLIBS    := -landroid -llog -lEGL -lGLESv1_CM -lOpenSLES -lGLESv2

And in AndroidManifest.xml is informed:

    <uses-feature android:glEsVersion="0x00020000"></uses-feature>

So, the program debugs and compiles with no problem. When set to run, comes the message:

    error  libEGL   called unimplemented OpenGL ES API

The Forum gives a suggestion workable for java - Android: GLES20: Called unimplemented OpenGL ES API , including to the code the command setEGLContextClientVersion:

    GLSurfaceView surfaceView = new GLSurfaceView(this);
    surfaceView.setEGLContextClientVersion(2);

However, the setEGLContextClientVersion is kind of a wrapper method meant for java.

The setEGLContextClientVersion does not belong to OpenGL ES native, and can not be applicable for native C++ OGLES development.

Therefore, I used instead:

const EGLint attribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2,EGL_NONE};
mContext = eglCreateContext(mDisplay, lConfig, EGL_NO_CONTEXT,attribList);

But the error has not gone away yet.

like image 266
ThreaderSlash Avatar asked Feb 27 '12 16:02

ThreaderSlash


1 Answers

Are you using real device (which?), or you are on emulator (which doesn't support OGL ES2)? Also I'm not sure if linking GLESv1_CM and GLESv2 in same app is a good idea. If you want OpenGL ES 2.0, then link only to GLESv2.

How did you initalized EGL context? Did you used EGL attribute EGL_OPENGL_ES2_BIT like:

EGLint aEGLAttributes[] =
{
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // <--- OpenGL ES 2.0
    ...
    EGL_NONE
};
...
eglChooseConfig(m_EGLDisplay, aEGLAttributes, aEGLConfigs, 1,
            &cEGLConfigs)
...
like image 84
Krystian Bigaj Avatar answered Oct 17 '22 14:10

Krystian Bigaj