android.opengl.GLUtils#getEGLErrorString ( )源码实例Demo

下面列出了android.opengl.GLUtils#getEGLErrorString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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()));
    }
}
 
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;
}
 
源代码3 项目: TurboLauncher   文件: BlockingGLTextureView.java
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;
}
 
源代码4 项目: StarWars.Android   文件: TextureHelper.java
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];
}
 
源代码5 项目: LB-Launcher   文件: BlockingGLTextureView.java
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;
}
 
源代码6 项目: opengl   文件: myGLTextureView.java
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();
    }
}
 
源代码7 项目: PhotoMovie   文件: GLTextureView.java
public static String formatEglError(String function, int error) {
    return function + " failed: " + GLUtils.getEGLErrorString(error);
}
 
源代码8 项目: ParsingPlayer   文件: VideoRenderThread.java
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()));
    }
}
 
源代码9 项目: opengl   文件: myGLTextureView.java
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();
    }
 
源代码10 项目: wear-os-samples   文件: Gles2ColoredTriangleList.java
/**
 * 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);
    }
}