Java Code Examples for javax.microedition.khronos.egl.EGL10#eglGetError()

The following examples show how to use javax.microedition.khronos.egl.EGL10#eglGetError() . 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: GOSurfaceView.java    From settlers-remake with MIT License 6 votes vote down vote up
@Override
public EGLContext createContext(EGL10 arg0, EGLDisplay display, EGLConfig config) {
	EGLContext newCtx = null;
	int i = 0;
	int[][] attrs = new int[][] {
			{EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, 2, EGL10.EGL_NONE}, //3.2
			{EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL10.EGL_NONE}, //3.1
			{EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, 3, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, 0, EGL10.EGL_NONE}, //3.0
			{EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}, // highest available version
			{EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, 1, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, 1, EGL10.EGL_NONE}, // 1.1
			{EGL14.EGL_CONTEXT_CLIENT_VERSION, 1, EGL10.EGL_NONE}, // 1.x
			{EGL10.EGL_NONE}, // lowest available version
	};

	while(newCtx == null && attrs.length >= i) {
		int[] attributes = attrs[i];
		newCtx = arg0.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, attributes);
		i++;
		if(newCtx != null && arg0.eglGetError() != EGL10.EGL_SUCCESS) {
			newCtx = null;
		}
	}
	return newCtx;
}
 
Example 2
Source File: EContextFactory.java    From SimpleVideoEdit with Apache License 2.0 5 votes vote down vote up
@Override
public void destroyContext(final EGL10 egl, final EGLDisplay display, final EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e(TAG, "display:" + display + " context: " + context);
        throw new RuntimeException("eglDestroyContex" + egl.eglGetError());
    }
}
 
Example 3
Source File: GlContextFactory.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
private static boolean checkEglError(String prompt, EGL10 egl) {
    int error;
    boolean result = true;
    while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
        result = false;
        log.error(String.format("%s: EGL error: 0x%x", prompt, error));
    }
    return result;
}
 
Example 4
Source File: ApplicationGLView.java    From cordova-plugin-vuforia with MIT License 5 votes vote down vote up
private static void checkEglError(String prompt, EGL10 egl)
{
    int error;
    while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS)
    {
        Log.e(LOGTAG, String.format("%s: EGL error: 0x%x", prompt, error));
    }
}
 
Example 5
Source File: PixelBuffer.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void checkEGLError(EGL10 egl) {
    int error = egl.eglGetError();
    if (BuildConfig.DEBUG) {
        if (error == EGL10.EGL_SUCCESS) {
            mLogger.info("EGL SUCCESS.");
        } else {
            mLogger.severe("EGL Error: " + error);
        }
    }
}
 
Example 6
Source File: ViEAndroidGLES20.java    From LiveVideo with Apache License 2.0 5 votes vote down vote up
private void printConfig(EGL10 egl, EGLDisplay display, EGLConfig config) {
	int[] attributes = { EGL10.EGL_BUFFER_SIZE, EGL10.EGL_ALPHA_SIZE, EGL10.EGL_BLUE_SIZE, EGL10.EGL_GREEN_SIZE, EGL10.EGL_RED_SIZE,
			EGL10.EGL_DEPTH_SIZE, EGL10.EGL_STENCIL_SIZE, EGL10.EGL_CONFIG_CAVEAT, EGL10.EGL_CONFIG_ID, EGL10.EGL_LEVEL, EGL10.EGL_MAX_PBUFFER_HEIGHT,
			EGL10.EGL_MAX_PBUFFER_PIXELS, EGL10.EGL_MAX_PBUFFER_WIDTH, EGL10.EGL_NATIVE_RENDERABLE, EGL10.EGL_NATIVE_VISUAL_ID,
			EGL10.EGL_NATIVE_VISUAL_TYPE,
			0x3030, // EGL10.EGL_PRESERVED_RESOURCES,
			EGL10.EGL_SAMPLES, EGL10.EGL_SAMPLE_BUFFERS, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_TRANSPARENT_TYPE, EGL10.EGL_TRANSPARENT_RED_VALUE,
			EGL10.EGL_TRANSPARENT_GREEN_VALUE, EGL10.EGL_TRANSPARENT_BLUE_VALUE, 0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB,
			0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA,
			0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL,
			0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL,
			EGL10.EGL_LUMINANCE_SIZE, EGL10.EGL_ALPHA_MASK_SIZE, EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RENDERABLE_TYPE, 0x3042 // EGL10.EGL_CONFORMANT
	};
	String[] names = { "EGL_BUFFER_SIZE", "EGL_ALPHA_SIZE", "EGL_BLUE_SIZE", "EGL_GREEN_SIZE", "EGL_RED_SIZE", "EGL_DEPTH_SIZE", "EGL_STENCIL_SIZE",
			"EGL_CONFIG_CAVEAT", "EGL_CONFIG_ID", "EGL_LEVEL", "EGL_MAX_PBUFFER_HEIGHT", "EGL_MAX_PBUFFER_PIXELS", "EGL_MAX_PBUFFER_WIDTH",
			"EGL_NATIVE_RENDERABLE", "EGL_NATIVE_VISUAL_ID", "EGL_NATIVE_VISUAL_TYPE", "EGL_PRESERVED_RESOURCES", "EGL_SAMPLES", "EGL_SAMPLE_BUFFERS",
			"EGL_SURFACE_TYPE", "EGL_TRANSPARENT_TYPE", "EGL_TRANSPARENT_RED_VALUE", "EGL_TRANSPARENT_GREEN_VALUE", "EGL_TRANSPARENT_BLUE_VALUE",
			"EGL_BIND_TO_TEXTURE_RGB", "EGL_BIND_TO_TEXTURE_RGBA", "EGL_MIN_SWAP_INTERVAL", "EGL_MAX_SWAP_INTERVAL", "EGL_LUMINANCE_SIZE",
			"EGL_ALPHA_MASK_SIZE", "EGL_COLOR_BUFFER_TYPE", "EGL_RENDERABLE_TYPE", "EGL_CONFORMANT" };
	int[] value = new int[1];
	for (int i = 0; i < attributes.length; i++) {
		int attribute = attributes[i];
		String name = names[i];
		if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
			Log.w(TAG, String.format("  %s: %d\n", name, value[0]));
		} else {
			Log.w(TAG, String.format("  %s: failed\n", name));
			while (egl.eglGetError() != EGL10.EGL_SUCCESS)
				;
		}
	}
}
 
Example 7
Source File: DefaultContextFactory.java    From CameraRecorder-android with MIT License 5 votes vote down vote up
@Override
public void destroyContext(final EGL10 egl, final EGLDisplay display, final EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e(TAG, "display:" + display + " context: " + context);
        throw new RuntimeException("eglDestroyContext" + egl.eglGetError());
    }
}
 
Example 8
Source File: SurfaceTextureRenderer.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
private static void checkEglError(String prompt, EGL10 egl)
{
    int error;
    while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS)
    {
        Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
    }
}
 
Example 9
Source File: DefaultContextFactory.java    From GPUVideo-android with MIT License 5 votes vote down vote up
@Override
public void destroyContext(final EGL10 egl, final EGLDisplay display, final EGLContext context) {
    if (!egl.eglDestroyContext(display, context)) {
        Log.e(TAG, "display:" + display + " context: " + context);
        throw new RuntimeException("eglDestroyContext" + egl.eglGetError());
    }
}
 
Example 10
Source File: VideoView.java    From NewsMe with Apache License 2.0 4 votes vote down vote up
private static void checkEglError(String prompt, EGL10 egl) {
	int error;
	while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
		LogS.d(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
	}
}
 
Example 11
Source File: VideoView.java    From NewsMe with Apache License 2.0 4 votes vote down vote up
private void printConfig(EGL10 egl, EGLDisplay display, EGLConfig config) {
	int[] attributes = { EGL10.EGL_BUFFER_SIZE, EGL10.EGL_ALPHA_SIZE,
			EGL10.EGL_BLUE_SIZE,
			EGL10.EGL_GREEN_SIZE,
			EGL10.EGL_RED_SIZE,
			EGL10.EGL_DEPTH_SIZE,
			EGL10.EGL_STENCIL_SIZE,
			EGL10.EGL_CONFIG_CAVEAT,
			EGL10.EGL_CONFIG_ID,
			EGL10.EGL_LEVEL,
			EGL10.EGL_MAX_PBUFFER_HEIGHT,
			EGL10.EGL_MAX_PBUFFER_PIXELS,
			EGL10.EGL_MAX_PBUFFER_WIDTH,
			EGL10.EGL_NATIVE_RENDERABLE,
			EGL10.EGL_NATIVE_VISUAL_ID,
			EGL10.EGL_NATIVE_VISUAL_TYPE,
			0x3030, // EGL10.EGL_PRESERVED_RESOURCES,
			EGL10.EGL_SAMPLES,
			EGL10.EGL_SAMPLE_BUFFERS,
			EGL10.EGL_SURFACE_TYPE,
			EGL10.EGL_TRANSPARENT_TYPE,
			EGL10.EGL_TRANSPARENT_RED_VALUE,
			EGL10.EGL_TRANSPARENT_GREEN_VALUE,
			EGL10.EGL_TRANSPARENT_BLUE_VALUE,
			0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB,
			0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA,
			0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL,
			0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL,
			EGL10.EGL_LUMINANCE_SIZE, EGL10.EGL_ALPHA_MASK_SIZE,
			EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RENDERABLE_TYPE,
			0x3042 // EGL10.EGL_CONFORMANT
	};
	String[] names = { "EGL_BUFFER_SIZE", "EGL_ALPHA_SIZE",
			"EGL_BLUE_SIZE", "EGL_GREEN_SIZE", "EGL_RED_SIZE",
			"EGL_DEPTH_SIZE", "EGL_STENCIL_SIZE", "EGL_CONFIG_CAVEAT",
			"EGL_CONFIG_ID", "EGL_LEVEL", "EGL_MAX_PBUFFER_HEIGHT",
			"EGL_MAX_PBUFFER_PIXELS", "EGL_MAX_PBUFFER_WIDTH",
			"EGL_NATIVE_RENDERABLE", "EGL_NATIVE_VISUAL_ID",
			"EGL_NATIVE_VISUAL_TYPE", "EGL_PRESERVED_RESOURCES",
			"EGL_SAMPLES", "EGL_SAMPLE_BUFFERS", "EGL_SURFACE_TYPE",
			"EGL_TRANSPARENT_TYPE", "EGL_TRANSPARENT_RED_VALUE",
			"EGL_TRANSPARENT_GREEN_VALUE",
			"EGL_TRANSPARENT_BLUE_VALUE", "EGL_BIND_TO_TEXTURE_RGB",
			"EGL_BIND_TO_TEXTURE_RGBA", "EGL_MIN_SWAP_INTERVAL",
			"EGL_MAX_SWAP_INTERVAL", "EGL_LUMINANCE_SIZE",
			"EGL_ALPHA_MASK_SIZE", "EGL_COLOR_BUFFER_TYPE",
			"EGL_RENDERABLE_TYPE", "EGL_CONFORMANT" };
	int[] value = new int[1];
	for (int i = 0; i < attributes.length; i++) {
		int attribute = attributes[i];
		String name = names[i];
		if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
			LogS.d(TAG, String.format("  %s: %d\n", name, value[0]));
		} else {
			// Log.w(TAG, String.format("  %s: failed\n", name));
			while (egl.eglGetError() != EGL10.EGL_SUCCESS)
				;
		}
	}
}
 
Example 12
Source File: ViEAndroidGLES20.java    From LiveVideo with Apache License 2.0 4 votes vote down vote up
private static void checkEglError(String prompt, EGL10 egl) {
	int error;
	while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
		Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
	}
}
 
Example 13
Source File: ViEAndroidGLES20.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
private void printConfig(EGL10 egl, EGLDisplay display,
        EGLConfig config) {
    int[] attributes = {
            EGL10.EGL_BUFFER_SIZE,
            EGL10.EGL_ALPHA_SIZE,
            EGL10.EGL_BLUE_SIZE,
            EGL10.EGL_GREEN_SIZE,
            EGL10.EGL_RED_SIZE,
            EGL10.EGL_DEPTH_SIZE,
            EGL10.EGL_STENCIL_SIZE,
            EGL10.EGL_CONFIG_CAVEAT,
            EGL10.EGL_CONFIG_ID,
            EGL10.EGL_LEVEL,
            EGL10.EGL_MAX_PBUFFER_HEIGHT,
            EGL10.EGL_MAX_PBUFFER_PIXELS,
            EGL10.EGL_MAX_PBUFFER_WIDTH,
            EGL10.EGL_NATIVE_RENDERABLE,
            EGL10.EGL_NATIVE_VISUAL_ID,
            EGL10.EGL_NATIVE_VISUAL_TYPE,
            0x3030, // EGL10.EGL_PRESERVED_RESOURCES,
            EGL10.EGL_SAMPLES,
            EGL10.EGL_SAMPLE_BUFFERS,
            EGL10.EGL_SURFACE_TYPE,
            EGL10.EGL_TRANSPARENT_TYPE,
            EGL10.EGL_TRANSPARENT_RED_VALUE,
            EGL10.EGL_TRANSPARENT_GREEN_VALUE,
            EGL10.EGL_TRANSPARENT_BLUE_VALUE,
            0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB,
            0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA,
            0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL,
            0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL,
            EGL10.EGL_LUMINANCE_SIZE,
            EGL10.EGL_ALPHA_MASK_SIZE,
            EGL10.EGL_COLOR_BUFFER_TYPE,
            EGL10.EGL_RENDERABLE_TYPE,
            0x3042 // EGL10.EGL_CONFORMANT
    };
    String[] names = {
            "EGL_BUFFER_SIZE",
            "EGL_ALPHA_SIZE",
            "EGL_BLUE_SIZE",
            "EGL_GREEN_SIZE",
            "EGL_RED_SIZE",
            "EGL_DEPTH_SIZE",
            "EGL_STENCIL_SIZE",
            "EGL_CONFIG_CAVEAT",
            "EGL_CONFIG_ID",
            "EGL_LEVEL",
            "EGL_MAX_PBUFFER_HEIGHT",
            "EGL_MAX_PBUFFER_PIXELS",
            "EGL_MAX_PBUFFER_WIDTH",
            "EGL_NATIVE_RENDERABLE",
            "EGL_NATIVE_VISUAL_ID",
            "EGL_NATIVE_VISUAL_TYPE",
            "EGL_PRESERVED_RESOURCES",
            "EGL_SAMPLES",
            "EGL_SAMPLE_BUFFERS",
            "EGL_SURFACE_TYPE",
            "EGL_TRANSPARENT_TYPE",
            "EGL_TRANSPARENT_RED_VALUE",
            "EGL_TRANSPARENT_GREEN_VALUE",
            "EGL_TRANSPARENT_BLUE_VALUE",
            "EGL_BIND_TO_TEXTURE_RGB",
            "EGL_BIND_TO_TEXTURE_RGBA",
            "EGL_MIN_SWAP_INTERVAL",
            "EGL_MAX_SWAP_INTERVAL",
            "EGL_LUMINANCE_SIZE",
            "EGL_ALPHA_MASK_SIZE",
            "EGL_COLOR_BUFFER_TYPE",
            "EGL_RENDERABLE_TYPE",
            "EGL_CONFORMANT"
    };
    int[] value = new int[1];
    for (int i = 0; i < attributes.length; i++) {
        int attribute = attributes[i];
        String name = names[i];
        if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
            Log.w(TAG, String.format("  %s: %d\n", name, value[0]));
        } else {
            // Log.w(TAG, String.format("  %s: failed\n", name));
            while (egl.eglGetError() != EGL10.EGL_SUCCESS);
        }
    }
}
 
Example 14
Source File: ViEAndroidGLES20.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
private static void checkEglError(String prompt, EGL10 egl) {
    int error;
    while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
        Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
    }
}
 
Example 15
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 16
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);
    }
}
 
Example 17
Source File: GLRender.java    From LiveBlurListView with Apache License 2.0 4 votes vote down vote up
public GLRender(int width, int height) {
	
	int[] version = new int[2];   
	EGLConfig[] configs = new EGLConfig[1];  
	int[] num_config = new int[1];  

	int[] configSpec ={  
			EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,   
			EGL10.EGL_RED_SIZE, 8,  
			EGL10.EGL_GREEN_SIZE, 8,  
			EGL10.EGL_BLUE_SIZE, 8,  
			EGL10.EGL_ALPHA_SIZE, 8,  
			EGL10.EGL_NONE   
	};  

	int attribListPbuffer[] = {  
			EGL10.EGL_WIDTH, width,  
			EGL10.EGL_HEIGHT, height,  
			EGL10.EGL_NONE  
	};
	
	mEgl = (EGL10)EGLContext.getEGL();
	mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

	mEgl.eglInitialize(mEglDisplay, version);

	mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1, num_config);

	EGLConfig mEglConfig = configs[0];

	mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig, EGL10.EGL_NO_CONTEXT, null);
	if (mEglContext == EGL10.EGL_NO_CONTEXT) {
		Log.d(TAG, "EGL_NO_CONTEXT");
	}

	mEglPBSurface = mEgl.eglCreatePbufferSurface(mEglDisplay, mEglConfig, attribListPbuffer);
	if (mEglPBSurface == EGL10.EGL_NO_SURFACE) {
		int errorcode = mEgl.eglGetError();
		switch(errorcode) {
		case EGL10.EGL_BAD_DISPLAY:
			Log.d(TAG, "EGL_BAD_DISPLAY");
			break;
		case EGL10.EGL_NOT_INITIALIZED:
			Log.d(TAG, "EGL_NOT_INITIALIZED");
			break;
		case EGL10.EGL_BAD_CONFIG:
			Log.d(TAG, "EGL_BAD_CONFIG");
			break;
		case EGL10.EGL_BAD_ATTRIBUTE:
			Log.d(TAG, "EGL_BAD_ATTRIBUTE");
			break;
		case EGL10.EGL_BAD_ALLOC:
			Log.d(TAG, "EGL_BAD_ALLOC");
			break;
		case EGL10.EGL_BAD_MATCH:
			Log.d(TAG, "EGL_BAD_MATCH");
			break;
		}				
	}


	if (!mEgl.eglMakeCurrent(mEglDisplay, mEglPBSurface, mEglPBSurface, mEglContext)) {
		Log.d(TAG, "bind failed code:" + mEgl.eglGetError());
	}

	mGL = (GL10) mEglContext.getGL();
	PixelBuffer = IntBuffer.allocate(width * height);
}
 
Example 18
Source File: ViEAndroidGLES20.java    From webrtc-app-mono with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void checkEglError(String prompt, EGL10 egl) {
    int error;
    while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) {
        Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
    }
}
 
Example 19
Source File: ViEAndroidGLES20.java    From webrtc-app-mono with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void printConfig(EGL10 egl, EGLDisplay display,
        EGLConfig config) {
    int[] attributes = {
            EGL10.EGL_BUFFER_SIZE,
            EGL10.EGL_ALPHA_SIZE,
            EGL10.EGL_BLUE_SIZE,
            EGL10.EGL_GREEN_SIZE,
            EGL10.EGL_RED_SIZE,
            EGL10.EGL_DEPTH_SIZE,
            EGL10.EGL_STENCIL_SIZE,
            EGL10.EGL_CONFIG_CAVEAT,
            EGL10.EGL_CONFIG_ID,
            EGL10.EGL_LEVEL,
            EGL10.EGL_MAX_PBUFFER_HEIGHT,
            EGL10.EGL_MAX_PBUFFER_PIXELS,
            EGL10.EGL_MAX_PBUFFER_WIDTH,
            EGL10.EGL_NATIVE_RENDERABLE,
            EGL10.EGL_NATIVE_VISUAL_ID,
            EGL10.EGL_NATIVE_VISUAL_TYPE,
            0x3030, // EGL10.EGL_PRESERVED_RESOURCES,
            EGL10.EGL_SAMPLES,
            EGL10.EGL_SAMPLE_BUFFERS,
            EGL10.EGL_SURFACE_TYPE,
            EGL10.EGL_TRANSPARENT_TYPE,
            EGL10.EGL_TRANSPARENT_RED_VALUE,
            EGL10.EGL_TRANSPARENT_GREEN_VALUE,
            EGL10.EGL_TRANSPARENT_BLUE_VALUE,
            0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB,
            0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA,
            0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL,
            0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL,
            EGL10.EGL_LUMINANCE_SIZE,
            EGL10.EGL_ALPHA_MASK_SIZE,
            EGL10.EGL_COLOR_BUFFER_TYPE,
            EGL10.EGL_RENDERABLE_TYPE,
            0x3042 // EGL10.EGL_CONFORMANT
    };
    String[] names = {
            "EGL_BUFFER_SIZE",
            "EGL_ALPHA_SIZE",
            "EGL_BLUE_SIZE",
            "EGL_GREEN_SIZE",
            "EGL_RED_SIZE",
            "EGL_DEPTH_SIZE",
            "EGL_STENCIL_SIZE",
            "EGL_CONFIG_CAVEAT",
            "EGL_CONFIG_ID",
            "EGL_LEVEL",
            "EGL_MAX_PBUFFER_HEIGHT",
            "EGL_MAX_PBUFFER_PIXELS",
            "EGL_MAX_PBUFFER_WIDTH",
            "EGL_NATIVE_RENDERABLE",
            "EGL_NATIVE_VISUAL_ID",
            "EGL_NATIVE_VISUAL_TYPE",
            "EGL_PRESERVED_RESOURCES",
            "EGL_SAMPLES",
            "EGL_SAMPLE_BUFFERS",
            "EGL_SURFACE_TYPE",
            "EGL_TRANSPARENT_TYPE",
            "EGL_TRANSPARENT_RED_VALUE",
            "EGL_TRANSPARENT_GREEN_VALUE",
            "EGL_TRANSPARENT_BLUE_VALUE",
            "EGL_BIND_TO_TEXTURE_RGB",
            "EGL_BIND_TO_TEXTURE_RGBA",
            "EGL_MIN_SWAP_INTERVAL",
            "EGL_MAX_SWAP_INTERVAL",
            "EGL_LUMINANCE_SIZE",
            "EGL_ALPHA_MASK_SIZE",
            "EGL_COLOR_BUFFER_TYPE",
            "EGL_RENDERABLE_TYPE",
            "EGL_CONFORMANT"
    };
    int[] value = new int[1];
    for (int i = 0; i < attributes.length; i++) {
        int attribute = attributes[i];
        String name = names[i];
        if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
            Log.w(TAG, String.format("  %s: %d\n", name, value[0]));
        } else {
            // Log.w(TAG, String.format("  %s: failed\n", name));
            while (egl.eglGetError() != EGL10.EGL_SUCCESS);
        }
    }
}