Java Code Examples for android.opengl.EGL14#EGL_BAD_NATIVE_WINDOW

The following examples show how to use android.opengl.EGL14#EGL_BAD_NATIVE_WINDOW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EGLBase.java    From Tok-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * change context to draw this window surface
 */
private boolean makeCurrent(final EGLSurface surface) {
    //		if (DEBUG) Log.v(TAG, "makeCurrent:");
    if (mEglDisplay == null) {
        LogUtil.i(TAG, "makeCurrent:eglDisplay not initialized");
    }
    if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
        final int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
        }
        return false;
    }
    // attach EGL renderring context to specific EGL window surface
    if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
        Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
        return false;
    }
    return true;
}
 
Example 2
Source File: EGLBase.java    From In77Camera with MIT License 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 3
Source File: EGLBase.java    From CameraRecorder-android with MIT License 6 votes vote down vote up
/**
     * change context to prepareDraw this window surface
     *
     * @return
     */
    boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (eglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(eglDisplay, surface, surface, eglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
    }
 
Example 4
Source File: EGLBase.java    From Fatigue-Detection with MIT License 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 5
Source File: EGLBase.java    From MegviiFacepp-Android-SDK with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 6
Source File: EGLBase.java    From UVCCameraZxing with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w("TAG", "eglMakeCurrent" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 7
Source File: EGLBase14.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
/*        if (mEglDisplay == null) {
			if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        } */
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL rendering context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mContext.eglContext)) {
            Log.w("TAG", "eglMakeCurrent" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 8
Source File: SohuEGLManager.java    From GLES2_AUDIO_VIDEO_RECODE with Apache License 2.0 6 votes vote down vote up
/**
 * change context to draw this window surface
 *
 * @return
 */
private boolean makeMyEGLCurrentSurface() {
    //
    if (mEglDisplay == null) {
        LogUtils.e(TAG, "mEglDisplay == null");
        return false;
    }
    if (mEglSurface == null || mEglSurface == EGL14.EGL_NO_SURFACE) {
        final int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            LogUtils.e(TAG, "makeMyEGLCurrentSurface:returned EGL_BAD_NATIVE_WINDOW.");
        }
        return false;
    }
    // EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx
    if (!EGL14.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
        Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
        return false;
    }
    return true;
}
 
Example 9
Source File: EGLBase.java    From TimeLapseRecordingSample with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 10
Source File: EGLBase.java    From AudioVideoPlayerSample with Apache License 2.0 6 votes vote down vote up
/**
 * change context to draw this window surface
 * @return
 */
private boolean makeCurrent(EGLSurface surface) {
	if (DEBUG) Log.v(TAG, "makeCurrent:");
       if (mEglDisplay == null) {
           if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
       }
       if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
           int error = EGL14.eglGetError();
           if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
               Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
           }
           return false;
       }
       // attach EGL renderring context to specific EGL window surface
       if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
           Log.w("TAG", "eglMakeCurrent" + EGL14.eglGetError());
           return false;
       }
       return true;
}
 
Example 11
Source File: EGLBase.java    From AudioVideoRecordingSample with Apache License 2.0 6 votes vote down vote up
/**
	 * change context to draw this window surface
	 * @return
	 */
	private boolean makeCurrent(final EGLSurface surface) {
//		if (DEBUG) Log.v(TAG, "makeCurrent:");
        if (mEglDisplay == null) {
            if (DEBUG) Log.d(TAG, "makeCurrent:eglDisplay not initialized");
        }
        if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
            final int error = EGL14.eglGetError();
            if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
            }
            return false;
        }
        // attach EGL renderring context to specific EGL window surface
        if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
            Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
            return false;
        }
        return true;
	}
 
Example 12
Source File: SurfaceTextureRenderer.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private boolean swapBuffers(EGLSurface surface)
        throws LegacyExceptionUtils.BufferQueueAbandonedException {
    boolean result = EGL14.eglSwapBuffers(mEGLDisplay, surface);

    int error = EGL14.eglGetError();
    switch (error) {
        case EGL14.EGL_SUCCESS:
            return result;

        // Check for an abandoned buffer queue, or other error conditions out
        // of the user's control.
        //
        // From the EGL 1.4 spec (2013-12-04), Section 3.9.4 Posting Errors:
        //
        //   If eglSwapBuffers is called and the native window associated with
        //   surface is no longer valid, an EGL_BAD_NATIVE_WINDOW error is
        //   generated.
        //
        // We also interpret EGL_BAD_SURFACE as indicating an abandoned
        // surface, even though the EGL spec does not document it as such, for
        // backwards compatibility with older versions of this file.
        case EGL14.EGL_BAD_NATIVE_WINDOW:
        case EGL14.EGL_BAD_SURFACE:
            throw new LegacyExceptionUtils.BufferQueueAbandonedException();

        default:
            throw new IllegalStateException(
                    "swapBuffers: EGL error: 0x" + Integer.toHexString(error));
    }
}
 
Example 13
Source File: EglHelperAPI17.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public boolean createSurface(Object surface) {
    if (mEglDisplay == null) {
        throw new RuntimeException("eglDisplay not initialized");
    }
    if (mEglConfig == null) {
        throw new RuntimeException("mEglConfig not initialized");
    }

    destroySurfaceImp();
    /*
     * Create an EGL surface we can render into.
     */
    mEglSurface = eglWindowSurfaceFactory.createWindowSurface(mEglDisplay, mEglConfig, surface);

    if (mEglSurface == null || mEglSurface == EGL14.EGL_NO_SURFACE) {
        int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            Log.e("EglHelper", "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
        }
        return false;
    }

    /*
     * Before we can issue GL commands, we need to make sure
     * the context is current and bound to a surface.
     */
    if (!EGL14.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
        /*
         * Could not make the context current, probably because the underlying
         * SurfaceView surface has been destroyed.
         */
        logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", EGL14.eglGetError());
        return false;
    }

    return true;
}
 
Example 14
Source File: EGLEnvironment.java    From EZFilter with MIT License 5 votes vote down vote up
private boolean makeCurrent(final EGLSurface surface) {
    if (surface == null || surface == EGL14.EGL_NO_SURFACE) {
        final int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            Log.e(TAG, "makeCurrent:returned EGL_BAD_NATIVE_WINDOW.");
        }
        return false;
    }
    // attach EGL renderring context to specific EGL window surface
    if (!EGL14.eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
        Log.w(TAG, "eglMakeCurrent:" + EGL14.eglGetError());
        return false;
    }
    return true;
}
 
Example 15
Source File: EglHelperAPI17.java    From android-openGL-canvas with Apache License 2.0 4 votes vote down vote up
@Override
public boolean createSurface(Object surface) {
    FileLogger.w(TAG, "createSurface()  tid=" + Thread.currentThread().getId());

    if (mEglDisplay == null) {
        throw new RuntimeException("eglDisplay not initialized");
    }
    if (mEglConfig == null) {
        throw new RuntimeException("mEglConfig not initialized");
    }

    destroySurfaceImp();
    /*
     * Create an EGL surface we can render into.
     */
    mEglSurface = eglWindowSurfaceFactory.createWindowSurface(mEglDisplay, mEglConfig, surface);

    if (mEglSurface == null || mEglSurface == EGL14.EGL_NO_SURFACE) {
        int error = EGL14.eglGetError();
        if (error == EGL14.EGL_BAD_NATIVE_WINDOW) {
            FileLogger.e(TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
        }
        FileLogger.e(TAG, "EGL_NO_SURFACE");
        return false;
    }

    /*
     * Before we can issue GL commands, we need to make sure
     * the context is current and bound to a surface.
     */
    if (!EGL14.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
        /*
         * Could not make the context current, probably because the underlying
         * SurfaceView surface has been destroyed.
         */
        logEglErrorAsWarning(TAG, "eglMakeCurrent", EGL14.eglGetError());
        return false;
    }

    return true;
}
 
Example 16
Source File: GLSurfaceView2.java    From java6-android-glframework with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Create an egl surface for the current SurfaceHolder surface. If a surface
 * already exists, destroy it before creating the new surface.
 *
 * @return true if the surface was created successfully.
 */
public boolean createSurface()
{
   if (s_LOG_EGL)
   {
      Log.w("EglHelper", "createSurface()  tid=" + Thread.currentThread().getId());
   }
      /*
       * Check preconditions.
       */
   if (mEglDisplay == null)
   {
      throw new RuntimeException("eglDisplay not initialized");
   }

   if (mEglConfig == null)
   {
      throw new RuntimeException("mEglConfig not initialized");
   }

      /*
       *  The window size has changed, so we need to create a new
       *  surface.
       */
   destroySurfaceImp();

      /*
       * Create an EGL surface we can render into.
       */
   GLSurfaceView2 view = mGLSurfaceViewWeakRef.get();
   if (view != null)
   {
      mEglSurface = view.eglWindowSurfaceFactory.createWindowSurface(mEglDisplay, mEglConfig, view.getHolder());
   }
   else
   {
      mEglSurface = null;
   }

   if (mEglSurface == null || mEglSurface == EGL14.EGL_NO_SURFACE)
   {
      int error = EGL14.eglGetError();
      if (error == EGL14.EGL_BAD_NATIVE_WINDOW)
      {
         Log.e("EglHelper", "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
      }
      return false;
   }

   /*
    * Before we can issue GL commands, we need to make sure
    * the context is current and bound to a surface.
    */
   if (!EGL14.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext))
   {
      /*
       * Could not make the context current, probably because the underlying
       * SurfaceView surface has been destroyed.
       */
      logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", EGL14.eglGetError());
      return false;
   }

   return true;
}