Code example for EGL10

Methods: eglDestroyContext, eglDestroySurface, eglGetError, eglMakeCurrent, eglSwapBuffers

0
        //Release the current context. 
        if (mEglDisplay == null) {
            Log.d(TAG, "EGLDisplay is null, cannot release EGL");
        } else { 
 
            if (!mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
                            EGL10.EGL_NO_CONTEXT)) {
                Log.d(TAG, "Could not make egl current with no display: " + mEgl.eglGetError() );
            } 
            if (mEglSurface == null) {
                Log.d(TAG, "EGLSurface is null");
            } else if (!mEgl.eglDestroySurface(mEglDisplay, mEglSurface)) {
                Log.d(TAG, "Could not destroy surface: " + mEgl.eglGetError() );
            } 
 
            if (mEglContext == null) {
                Log.d(TAG, "EGLContext is null");
            } else if (!mEgl.eglDestroyContext(mEglDisplay, mEglContext)) {
                    Log.d(TAG, "Could not destroy context: " + mEgl.eglGetError() );
 
            } 
        } 
 
    } 
 
    @Override 
    public boolean swapBuffers() { 
 
        if (!mDisableSwapBuffer)   {
            boolean result = mEgl.eglSwapBuffers(mEglDisplay, mEglSurface);
            if (!result)    {
                Log.d(TAG, "Could not swap buffers: " + mEgl.eglGetError());
                releaseEGL(); 
//                createEGL(null); 
            } 
            return result;