javax.microedition.khronos.egl.EGL11 Java Examples

The following examples show how to use javax.microedition.khronos.egl.EGL11. 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: GLRecoder.java    From OpenGLESRecorder with Apache License 2.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
    int renderableType = 4;

    // The actual surface is generally RGBA or RGBX, so situationally omitting alpha
    // doesn't really help.  It can also lead to a huge performance hit on glReadPixels()
    // when reading into a GL_RGBA buffer.
    int[] attribList = {
            EGL11.EGL_RED_SIZE, 8,
            EGL11.EGL_GREEN_SIZE, 8,
            EGL11.EGL_BLUE_SIZE, 8,
            EGL11.EGL_ALPHA_SIZE, 8,
            //EGL11.EGL_DEPTH_SIZE, 16,
            //EGL11.EGL_STENCIL_SIZE, 8,
            EGL11.EGL_RENDERABLE_TYPE, renderableType,
            EGL_RECORDABLE_ANDROID, 1,      // set recordable [@-3]
            EGL11.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!egl.eglChooseConfig(display, attribList, configs, configs.length,
            numConfigs)) {
        return null;
    }
    return configs[0];
}
 
Example #2
Source File: EGL.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #3
Source File: EGL.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #4
Source File: EGL.java    From video-player with MIT License 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #5
Source File: EGL.java    From NetEasyNews with GNU General Public License v3.0 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #6
Source File: EGL.java    From react-native-android-vitamio with MIT License 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #7
Source File: EGL.java    From Vitamio with Apache License 2.0 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #8
Source File: EGL.java    From BambooPlayer with Apache License 2.0 6 votes vote down vote up
public boolean swap() {
  if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
    int error = mEgl.eglGetError();
    switch (error) {
      case EGL11.EGL_CONTEXT_LOST:
        return false;
      case EGL10.EGL_BAD_NATIVE_WINDOW:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid=" + Thread.currentThread().getId());
        break;
      case EGL10.EGL_BAD_SURFACE:
        Log.e("EglHelper", "eglSwapBuffers returned EGL_BAD_SURFACE. tid=" + Thread.currentThread().getId());
        return false;
      default:
        throwEglException("eglSwapBuffers", error);
    }
  }
  return true;
}
 
Example #9
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public static String getErrorString(int error) {
    switch (error) {
        case EGL_SUCCESS:
            return "EGL_SUCCESS";
        case EGL_NOT_INITIALIZED:
            return "EGL_NOT_INITIALIZED";
        case EGL_BAD_ACCESS:
            return "EGL_BAD_ACCESS";
        case EGL_BAD_ALLOC:
            return "EGL_BAD_ALLOC";
        case EGL_BAD_ATTRIBUTE:
            return "EGL_BAD_ATTRIBUTE";
        case EGL_BAD_CONFIG:
            return "EGL_BAD_CONFIG";
        case EGL_BAD_CONTEXT:
            return "EGL_BAD_CONTEXT";
        case EGL_BAD_CURRENT_SURFACE:
            return "EGL_BAD_CURRENT_SURFACE";
        case EGL_BAD_DISPLAY:
            return "EGL_BAD_DISPLAY";
        case EGL_BAD_MATCH:
            return "EGL_BAD_MATCH";
        case EGL_BAD_NATIVE_PIXMAP:
            return "EGL_BAD_NATIVE_PIXMAP";
        case EGL_BAD_NATIVE_WINDOW:
            return "EGL_BAD_NATIVE_WINDOW";
        case EGL_BAD_PARAMETER:
            return "EGL_BAD_PARAMETER";
        case EGL_BAD_SURFACE:
            return "EGL_BAD_SURFACE";
        case EGL11.EGL_CONTEXT_LOST:
            return "EGL_CONTEXT_LOST";
        default:
            return getHex(error);
    }
}
 
Example #10
Source File: GLSurfaceView.java    From EZFilter with MIT License 5 votes vote down vote up
static String eglGetErrorString(int error) {
    switch (error) {
        case EGL11.EGL_SUCCESS:
            return "EGL_SUCCESS";
        case EGL11.EGL_NOT_INITIALIZED:
            return "EGL_NOT_INITIALIZED";
        case EGL11.EGL_BAD_ACCESS:
            return "EGL_BAD_ACCESS";
        case EGL11.EGL_BAD_ALLOC:
            return "EGL_BAD_ALLOC";
        case EGL11.EGL_BAD_ATTRIBUTE:
            return "EGL_BAD_ATTRIBUTE";
        case EGL11.EGL_BAD_CONFIG:
            return "EGL_BAD_CONFIG";
        case EGL11.EGL_BAD_CONTEXT:
            return "EGL_BAD_CONTEXT";
        case EGL11.EGL_BAD_CURRENT_SURFACE:
            return "EGL_BAD_CURRENT_SURFACE";
        case EGL11.EGL_BAD_DISPLAY:
            return "EGL_BAD_DISPLAY";
        case EGL11.EGL_BAD_MATCH:
            return "EGL_BAD_MATCH";
        case EGL11.EGL_BAD_NATIVE_PIXMAP:
            return "EGL_BAD_NATIVE_PIXMAP";
        case EGL11.EGL_BAD_NATIVE_WINDOW:
            return "EGL_BAD_NATIVE_WINDOW";
        case EGL11.EGL_BAD_PARAMETER:
            return "EGL_BAD_PARAMETER";
        case EGL11.EGL_BAD_SURFACE:
            return "EGL_BAD_SURFACE";
        case EGL11.EGL_CONTEXT_LOST:
            return "EGL_CONTEXT_LOST";
        default:
            return "0x" + Integer.toHexString(error);
    }
}
 
Example #11
Source File: GLTextureView.java    From EZFilter with MIT License 5 votes vote down vote up
static String eglGetErrorString(int error) {
    switch (error) {
        case EGL11.EGL_SUCCESS:
            return "EGL_SUCCESS";
        case EGL11.EGL_NOT_INITIALIZED:
            return "EGL_NOT_INITIALIZED";
        case EGL11.EGL_BAD_ACCESS:
            return "EGL_BAD_ACCESS";
        case EGL11.EGL_BAD_ALLOC:
            return "EGL_BAD_ALLOC";
        case EGL11.EGL_BAD_ATTRIBUTE:
            return "EGL_BAD_ATTRIBUTE";
        case EGL11.EGL_BAD_CONFIG:
            return "EGL_BAD_CONFIG";
        case EGL11.EGL_BAD_CONTEXT:
            return "EGL_BAD_CONTEXT";
        case EGL11.EGL_BAD_CURRENT_SURFACE:
            return "EGL_BAD_CURRENT_SURFACE";
        case EGL11.EGL_BAD_DISPLAY:
            return "EGL_BAD_DISPLAY";
        case EGL11.EGL_BAD_MATCH:
            return "EGL_BAD_MATCH";
        case EGL11.EGL_BAD_NATIVE_PIXMAP:
            return "EGL_BAD_NATIVE_PIXMAP";
        case EGL11.EGL_BAD_NATIVE_WINDOW:
            return "EGL_BAD_NATIVE_WINDOW";
        case EGL11.EGL_BAD_PARAMETER:
            return "EGL_BAD_PARAMETER";
        case EGL11.EGL_BAD_SURFACE:
            return "EGL_BAD_SURFACE";
        case EGL11.EGL_CONTEXT_LOST:
            return "EGL_CONTEXT_LOST";
        default:
            return "0x" + Integer.toHexString(error);
    }
}
 
Example #12
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
public static String getErrorString(int error) {
    switch (error) {
        case EGL_SUCCESS:
            return "EGL_SUCCESS";
        case EGL_NOT_INITIALIZED:
            return "EGL_NOT_INITIALIZED";
        case EGL_BAD_ACCESS:
            return "EGL_BAD_ACCESS";
        case EGL_BAD_ALLOC:
            return "EGL_BAD_ALLOC";
        case EGL_BAD_ATTRIBUTE:
            return "EGL_BAD_ATTRIBUTE";
        case EGL_BAD_CONFIG:
            return "EGL_BAD_CONFIG";
        case EGL_BAD_CONTEXT:
            return "EGL_BAD_CONTEXT";
        case EGL_BAD_CURRENT_SURFACE:
            return "EGL_BAD_CURRENT_SURFACE";
        case EGL_BAD_DISPLAY:
            return "EGL_BAD_DISPLAY";
        case EGL_BAD_MATCH:
            return "EGL_BAD_MATCH";
        case EGL_BAD_NATIVE_PIXMAP:
            return "EGL_BAD_NATIVE_PIXMAP";
        case EGL_BAD_NATIVE_WINDOW:
            return "EGL_BAD_NATIVE_WINDOW";
        case EGL_BAD_PARAMETER:
            return "EGL_BAD_PARAMETER";
        case EGL_BAD_SURFACE:
            return "EGL_BAD_SURFACE";
        case EGL11.EGL_CONTEXT_LOST:
            return "EGL_CONTEXT_LOST";
        default:
            return getHex(error);
    }
}
 
Example #13
Source File: GLSurfaceView.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
/**
 * Display the current render surface.
 * 
 * @return false if the context has been lost.
 */
public boolean swap() {
	if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {

		/*
		 * Check for EGL_CONTEXT_LOST, which means the context and all
		 * associated data were lost (For instance because the device
		 * went to sleep). We need to sleep until we get a new surface.
		 */
		int error = mEgl.eglGetError();
		switch (error) {
		case EGL11.EGL_CONTEXT_LOST:
			return false;
		case EGL10.EGL_BAD_NATIVE_WINDOW:
			// The native window is bad, probably because the
			// window manager has closed it. Ignore this error,
			// on the expectation that the application will be
			// closed soon.
			Log.e("EglHelper",
					"eglSwapBuffers returned EGL_BAD_NATIVE_WINDOW. tid="
							+ Thread.currentThread().getId());
			break;
		default:
			throwEglException("eglSwapBuffers", error);
		}
	}
	return true;
}
 
Example #14
Source File: RendererUtil.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Checks for an EGL error and throws a {@link RendererException} if there
 * is one. Ignores the value of {@link RendererUtil#ENABLE_ERROR_CHECKING}.
 */
public static void checkEGLError(EGL10 egl) {
    int error = egl.eglGetError();
    if (error != EGL10.EGL_SUCCESS) {
        String errorMessage;
        switch (error) {
            case EGL10.EGL_SUCCESS:
                return;
            case EGL10.EGL_NOT_INITIALIZED:
                errorMessage = "EGL is not initialized, or could not be "
                        + "initialized, for the specified EGL display connection. ";
                break;
            case EGL10.EGL_BAD_ACCESS:
                errorMessage = "EGL cannot access a requested resource "
                        + "(for example a context is bound in another thread). ";
                break;
            case EGL10.EGL_BAD_ALLOC:
                errorMessage = "EGL failed to allocate resources for the requested operation.";
                break;
            case EGL10.EGL_BAD_ATTRIBUTE:
                errorMessage = "An unrecognized attribute or attribute "
                        + "value was passed in the attribute list. ";
                break;
            case EGL10.EGL_BAD_CONTEXT:
                errorMessage = "An EGLContext argument does not name a valid EGL rendering context. ";
                break;
            case EGL10.EGL_BAD_CONFIG:
                errorMessage = "An EGLConfig argument does not name a valid EGL frame buffer configuration. ";
                break;
            case EGL10.EGL_BAD_CURRENT_SURFACE:
                errorMessage = "The current surface of the calling thread "
                        + "is a window, pixel buffer or pixmap that is no longer valid. ";
                break;
            case EGL10.EGL_BAD_DISPLAY:
                errorMessage = "An EGLDisplay argument does not name a valid EGL display connection. ";
                break;
            case EGL10.EGL_BAD_SURFACE:
                errorMessage = "An EGLSurface argument does not name a "
                        + "valid surface (window, pixel buffer or pixmap) configured for GL rendering. ";
                break;
            case EGL10.EGL_BAD_MATCH:
                errorMessage = "Arguments are inconsistent (for example, a "
                        + "valid context requires buffers not supplied by a valid surface). ";
                break;
            case EGL10.EGL_BAD_PARAMETER:
                errorMessage = "One or more argument values are invalid.";
                break;
            case EGL10.EGL_BAD_NATIVE_PIXMAP:
                errorMessage = "A NativePixmapType argument does not refer to a valid native pixmap. ";
                break;
            case EGL10.EGL_BAD_NATIVE_WINDOW:
                errorMessage = "A NativeWindowType argument does not refer to a valid native window. ";
                break;
            case EGL11.EGL_CONTEXT_LOST:
                errorMessage = "A power management event has occurred. "
                        + "The application must destroy all contexts and reinitialise "
                        + "OpenGL ES state and objects to continue rendering. ";
                break;
            default:
                errorMessage = "Unknown";
        }
        
        throw new RendererException("EGL error 0x" + Integer.toHexString(error) + ": " + errorMessage);
    }
}