Search in sources :

Example 1 with EGL10

use of javax.microedition.khronos.egl.EGL10 in project Rajawali by Rajawali.

the class Capabilities method checkGLVersion.

private static void checkGLVersion() {
    // Get an EGL context and display
    final EGL10 egl = (EGL10) EGLContext.getEGL();
    final EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    final int[] version = new int[2];
    if (!egl.eglInitialize(display, version))
        throw new IllegalStateException("Failed to initialize an EGL context while getting device capabilities.");
    mEGLMajorVersion = version[0];
    mEGLMinorVersion = version[1];
    // RajLog.d("Device EGL Version: " + version[0] + "." + version[1]);
    // Assume GLES 2 by default
    mGLESMajorVersion = 2;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        // The API for GLES3 might exist, we need to check
        // RajLog.d("Attempting to get an OpenGL ES 3 config.");
        checkGLVersionIs3(egl, display);
    }
    egl.eglTerminate(display);
    // RajLog.d("Determined GLES Major version to be: " + mGLESMajorVersion);
    sGLChecked = true;
}
Also used : EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay)

Example 2 with EGL10

use of javax.microedition.khronos.egl.EGL10 in project Signal-Android by WhisperSystems.

the class BitmapUtil method getMaxTextureSize.

public static int getMaxTextureSize() {
    final int IMAGE_MAX_BITMAP_DIMENSION = 2048;
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    int[] version = new int[2];
    egl.eglInitialize(display, version);
    int[] totalConfigurations = new int[1];
    egl.eglGetConfigs(display, null, 0, totalConfigurations);
    EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
    egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);
    int[] textureSize = new int[1];
    int maximumTextureSize = 0;
    for (int i = 0; i < totalConfigurations[0]; i++) {
        egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
        if (maximumTextureSize < textureSize[0])
            maximumTextureSize = textureSize[0];
    }
    egl.eglTerminate(display);
    return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION);
}
Also used : EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 3 with EGL10

use of javax.microedition.khronos.egl.EGL10 in project AndEngine by nicolasgramlich.

the class AndEngine method checkEGLConfigChooserSupport.

private static void checkEGLConfigChooserSupport() throws DeviceNotSupportedException {
    /* Get an EGL instance. */
    final EGL10 egl = (EGL10) EGLContext.getEGL();
    /* Get to the default display. */
    final EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    /* We can now initialize EGL for that display. */
    final int[] version = new int[2];
    egl.eglInitialize(eglDisplay, version);
    // TODO Doesn't correlate to possible multisampling request in EngineOptions...
    final ConfigChooser configChooser = new ConfigChooser(false);
    try {
        configChooser.chooseConfig(egl, eglDisplay);
    } catch (final IllegalArgumentException e) {
        throw new DeviceNotSupportedException(DeviceNotSupportedCause.EGLCONFIG_NOT_FOUND, e);
    }
}
Also used : EGL10(javax.microedition.khronos.egl.EGL10) ConfigChooser(org.andengine.opengl.view.ConfigChooser) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) DeviceNotSupportedException(org.andengine.util.exception.DeviceNotSupportedException)

Example 4 with EGL10

use of javax.microedition.khronos.egl.EGL10 in project platform_frameworks_base by android.

the class RenderTarget method focusNone.

public static void focusNone() {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    egl.eglMakeCurrent(egl.eglGetCurrentDisplay(), EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    mCurrentTarget.set(null);
    checkEglError(egl, "eglMakeCurrent");
}
Also used : EGL10(javax.microedition.khronos.egl.EGL10)

Example 5 with EGL10

use of javax.microedition.khronos.egl.EGL10 in project platform_frameworks_base by android.

the class RenderTarget method newTarget.

public static RenderTarget newTarget(int width, int height) {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay eglDisplay = createDefaultDisplay(egl);
    EGLConfig eglConfig = chooseEglConfig(egl, eglDisplay);
    EGLContext eglContext = createContext(egl, eglDisplay, eglConfig);
    EGLSurface eglSurface = createSurface(egl, eglDisplay, width, height);
    RenderTarget result = new RenderTarget(eglDisplay, eglContext, eglSurface, 0, true, true);
    result.addReferenceTo(eglSurface);
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) EGLContext(javax.microedition.khronos.egl.EGLContext) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Aggregations

EGL10 (javax.microedition.khronos.egl.EGL10)22 EGLDisplay (javax.microedition.khronos.egl.EGLDisplay)16 EGLConfig (javax.microedition.khronos.egl.EGLConfig)12 EGLContext (javax.microedition.khronos.egl.EGLContext)9 EGLSurface (javax.microedition.khronos.egl.EGLSurface)8 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 Paint (android.graphics.Paint)1 EGLConfig (android.opengl.EGLConfig)1 TextPaint (android.text.TextPaint)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ConfigChooser (org.andengine.opengl.view.ConfigChooser)1 DeviceNotSupportedException (org.andengine.util.exception.DeviceNotSupportedException)1