Java Code Examples for android.opengl.GLUtils#getEGLErrorString()

The following examples show how to use android.opengl.GLUtils#getEGLErrorString() . 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: TextureSurfaceRenderer.java    From AndroidOpenGLVideoDemo with Apache License 2.0 6 votes vote down vote up
private void initGL()
{
    egl = (EGL10) EGLContext.getEGL();
    eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    int[] version = new int[2];
    egl.eglInitialize(eglDisplay, version);

    EGLConfig eglConfig = chooseEglConfig();
    eglContext = createContext(egl, eglDisplay, eglConfig);

    eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, texture, null);

    if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE)
    {
        throw new RuntimeException("GL Error: " + GLUtils.getEGLErrorString(egl.eglGetError()));
    }

    if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext))
    {
        throw new RuntimeException("GL Make current error: " + GLUtils.getEGLErrorString(egl.eglGetError()));
    }
}
 
Example 2
Source File: TextureSurfaceRenderer.java    From AndroidOpenGLVideoDemo with Apache License 2.0 6 votes vote down vote up
private EGLConfig chooseEglConfig()
{
    int[] configsCount = new int[1];
    EGLConfig[] configs = new EGLConfig[1];
    int[] configSpec = getConfig();

    if (!egl.eglChooseConfig(eglDisplay, configSpec, configs, 1, configsCount))
    {
        throw new IllegalArgumentException("Failed to choose config: " + GLUtils.getEGLErrorString(egl.eglGetError()));
    }
    else if (configsCount[0] > 0)
    {
        return configs[0];
    }

    return null;
}
 
Example 3
Source File: BlockingGLTextureView.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private EGLConfig chooseEglConfig() {
    int[] configsCount = new int[1];
    EGLConfig[] configs = new EGLConfig[1];
    int[] configSpec = getConfig();
    if (!mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1, configsCount)) {
        throw new IllegalArgumentException("eglChooseConfig failed " +
                GLUtils.getEGLErrorString(mEgl.eglGetError()));
    } else if (configsCount[0] > 0) {
        return configs[0];
    }
    return null;
}
 
Example 4
Source File: TextureHelper.java    From StarWars.Android with MIT License 5 votes vote down vote up
public static int loadTexture(final Bitmap bitmap) {
	final int[] textureHandle = new int[1];

	glGenTextures(1, textureHandle, 0);

	if (textureHandle[0] != 0) {
		// Bind to the texture in OpenGL
		glBindTexture(GL_TEXTURE_2D, textureHandle[0]);

		// Set filtering
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

		// Load the bitmap into the bound texture.
		GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);

		// Recycle the bitmap, since its data has been loaded into OpenGL.
		bitmap.recycle();
	} else {
		int errorCode = GLES20.glGetError();
           String errorString = GLUtils.getEGLErrorString(errorCode);
           RuntimeException e = new RuntimeException(errorCode + " " + errorString);
		Timber.e(e, "");
		throw e;
	}

	return textureHandle[0];
}
 
Example 5
Source File: BlockingGLTextureView.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
private EGLConfig chooseEglConfig() {
    int[] configsCount = new int[1];
    EGLConfig[] configs = new EGLConfig[1];
    int[] configSpec = getConfig();
    if (!mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1, configsCount)) {
        throw new IllegalArgumentException("eglChooseConfig failed " +
                GLUtils.getEGLErrorString(mEgl.eglGetError()));
    } else if (configsCount[0] > 0) {
        return configs[0];
    }
    return null;
}
 
Example 6
Source File: myGLTextureView.java    From opengl with Apache License 2.0 5 votes vote down vote up
private void checkCurrent() {
    if (!mEglContext.equals(mEgl.eglGetCurrentContext())
            || !mEglSurface.equals(mEgl
            .eglGetCurrentSurface(EGL10.EGL_DRAW))) {
        checkEglError();
        if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface,
                mEglSurface, mEglContext)) {
            throw new RuntimeException(
                    "eglMakeCurrent failed "
                            + GLUtils.getEGLErrorString(mEgl
                            .eglGetError()));
        }
        checkEglError();
    }
}
 
Example 7
Source File: GLTextureView.java    From PhotoMovie with Apache License 2.0 4 votes vote down vote up
public static String formatEglError(String function, int error) {
    return function + " failed: " + GLUtils.getEGLErrorString(error);
}
 
Example 8
Source File: VideoRenderThread.java    From ParsingPlayer with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void raiseEGLInitError() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        throw new RuntimeException("EGL INIT ERROR " + egl10.eglGetError() + " " +
                GLUtils.getEGLErrorString(egl10.eglGetError()));
    }
}
 
Example 9
Source File: myGLTextureView.java    From opengl with Apache License 2.0 4 votes vote down vote up
private void initGL() {

        mEgl = (EGL10) EGLContext.getEGL();
        mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
        if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
            throw new RuntimeException("eglGetDisplay failed "
                    + GLUtils.getEGLErrorString(mEgl.eglGetError()));
        }
        int[] version = new int[2];
        if (!mEgl.eglInitialize(mEglDisplay, version)) {
            throw new RuntimeException("eglInitialize failed "
                    + GLUtils.getEGLErrorString(mEgl.eglGetError()));
        }
        int[] configsCount = new int[1];
        EGLConfig[] configs = new EGLConfig[1];
        int[] configSpec = {
                EGL10.EGL_RENDERABLE_TYPE,
                EGL_OPENGL_ES2_BIT,
                EGL10.EGL_RED_SIZE, 8,
                EGL10.EGL_GREEN_SIZE, 8,
                EGL10.EGL_BLUE_SIZE, 8,
                EGL10.EGL_ALPHA_SIZE, 8,
                EGL10.EGL_DEPTH_SIZE, 16,  //was 0
                EGL10.EGL_STENCIL_SIZE, 0,
                EGL10.EGL_NONE
        };
        eglConfig = null;
        if (!mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1,
                configsCount)) {
            throw new IllegalArgumentException(
                    "eglChooseConfig failed "
                            + GLUtils.getEGLErrorString(mEgl
                            .eglGetError()));
        } else if (configsCount[0] > 0) {
            eglConfig = configs[0];
        }
        if (eglConfig == null) {
            throw new RuntimeException("eglConfig not initialized");
        }
        int[] attrib_list = {
                EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE
        };
        mEglContext = mEgl.eglCreateContext(mEglDisplay,
                eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
        checkEglError();
        mEglSurface = mEgl.eglCreateWindowSurface(
                mEglDisplay, eglConfig, mSurface, null);
        checkEglError();
        if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) {
            int error = mEgl.eglGetError();
            if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
                Log.e(TAG,
                        "eglCreateWindowSurface returned EGL10.EGL_BAD_NATIVE_WINDOW");
                return;
            }
            throw new RuntimeException(
                    "eglCreateWindowSurface failed "
                            + GLUtils.getEGLErrorString(error));
        }
        if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface,
                mEglSurface, mEglContext)) {
            throw new RuntimeException("eglMakeCurrent failed "
                    + GLUtils.getEGLErrorString(mEgl.eglGetError()));
        }
        checkEglError();
        mGl = (GL10) mEglContext.getGL();
        checkEglError();
    }
 
Example 10
Source File: Gles2ColoredTriangleList.java    From wear-os-samples with Apache License 2.0 3 votes vote down vote up
/**
 * Checks if any of the GL calls since the last time this method was called set an error
 * condition. Call this method immediately after calling a GL method. Pass the name of the GL
 * operation. For example:
 *
 * <pre>
 * mColorHandle = GLES20.glGetUniformLocation(mProgram, "uColor");
 * MyGLRenderer.checkGlError("glGetUniformLocation");</pre>
 *
 * If the operation is not successful, the check throws an exception.
 *
 * <p><em>Note</em> This is quite slow so it's best to use it sparingly in production builds.
 *
 * @param glOperation name of the OpenGL call to check
 */
private static void checkGlError(String glOperation) {
    int error = GLES20.glGetError();
    if (error != GLES20.GL_NO_ERROR) {
        String errorString = GLU.gluErrorString(error);
        if (errorString == null) {
            errorString = GLUtils.getEGLErrorString(error);
        }
        String message = glOperation + " caused GL error 0x" + Integer.toHexString(error) +
                ": " + errorString;
        Log.e(TAG, message);
        throw new RuntimeException(message);
    }
}