Search in sources :

Example 31 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project libgdx by libgdx.

the class AndroidGraphics method checkGL20.

protected boolean checkGL20() {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    int[] version = new int[2];
    egl.eglInitialize(display, version);
    int EGL_OPENGL_ES2_BIT = 4;
    int[] configAttribs = { EGL10.EGL_RED_SIZE, 4, EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE };
    EGLConfig[] configs = new EGLConfig[10];
    int[] num_config = new int[1];
    egl.eglChooseConfig(display, configAttribs, configs, 10, num_config);
    egl.eglTerminate(display);
    return num_config[0] > 0;
}
Also used : EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 32 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project muzei by romannurik.

the class BaseConfigChooser method chooseConfig.

public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
    int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }
    int numConfigs = num_config[0];
    if (numConfigs <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
    }
    EGLConfig[] configs = new EGLConfig[numConfigs];
    if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
Also used : EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 33 with EGLConfig

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

the class ConfigChooser method findEGLConfig.

private EGLConfig findEGLConfig(final EGL10 pEGL, final EGLDisplay pEGLDisplay, final EGLConfig[] pEGLConfigs, final ConfigChooserMatcher pConfigChooserMatcher) {
    for (int i = 0; i < pEGLConfigs.length; ++i) {
        final EGLConfig config = pEGLConfigs[i];
        if (config != null) {
            final int redSize = ConfigChooser.getConfigAttrib(pEGL, pEGLDisplay, config, EGL10.EGL_RED_SIZE, 0);
            final int greenSize = ConfigChooser.getConfigAttrib(pEGL, pEGLDisplay, config, EGL10.EGL_GREEN_SIZE, 0);
            final int blueSize = ConfigChooser.getConfigAttrib(pEGL, pEGLDisplay, config, EGL10.EGL_BLUE_SIZE, 0);
            final int alphaSize = ConfigChooser.getConfigAttrib(pEGL, pEGLDisplay, config, EGL10.EGL_ALPHA_SIZE, 0);
            final int depthSize = ConfigChooser.getConfigAttrib(pEGL, pEGLDisplay, config, EGL10.EGL_DEPTH_SIZE, 0);
            final int stencilSize = ConfigChooser.getConfigAttrib(pEGL, pEGLDisplay, config, EGL10.EGL_STENCIL_SIZE, 0);
            if (pConfigChooserMatcher.matches(redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize)) {
                this.mRedSize = redSize;
                this.mGreenSize = greenSize;
                this.mBlueSize = blueSize;
                this.mAlphaSize = alphaSize;
                this.mDepthSize = depthSize;
                this.mStencilSize = stencilSize;
                return config;
            }
        }
    }
    throw new IllegalArgumentException("No EGLConfig found!");
}
Also used : EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 34 with EGLConfig

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

the class Capabilities method checkGLVersionIs3.

@TargetApi(VERSION_CODES.JELLY_BEAN_MR2)
private static void checkGLVersionIs3(@NonNull EGL10 egl, EGLDisplay display) {
    // Find out how many EGLConfigs exist
    final int[] num_config = new int[1];
    egl.eglGetConfigs(display, null, 0, num_config);
    // Allocate and retrieve the EGLConfigs/handles
    int configCount = num_config[0];
    final EGLConfig[] configs = new EGLConfig[configCount];
    egl.eglGetConfigs(display, configs, configCount, num_config);
    // Check for a config that supports GLES 3 (using a manual search rather than
    // eglChooseConfig(), which may simply ignore the new ES3 bit on older versions)
    final int[] value = new int[1];
    for (EGLConfig config : configs) {
        egl.eglGetConfigAttrib(display, config, EGL10.EGL_RENDERABLE_TYPE, value);
        if ((value[0] & EGLExt.EGL_OPENGL_ES3_BIT_KHR) != 0) {
            // TODO is this secondary check for color sizes useful?
            // We have at least one GLES 3 config, can now use eglChooseConfig()
            // to see if one of them has at least 4 bits per color
            final int[] configAttribs = { EGL10.EGL_RED_SIZE, 4, EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4, EGL10.EGL_RENDERABLE_TYPE, EGLExt.EGL_OPENGL_ES3_BIT_KHR, EGL10.EGL_NONE };
            value[0] = 0;
            egl.eglChooseConfig(display, configAttribs, configs, 1, value);
            mGLESMajorVersion = value[0] > 0 ? 3 : 2;
            break;
        }
    }
}
Also used : EGLConfig(javax.microedition.khronos.egl.EGLConfig) TargetApi(android.annotation.TargetApi)

Example 35 with EGLConfig

use of javax.microedition.khronos.egl.EGLConfig in project StickerCamera by Skykai521.

the class PixelBuffer method listConfig.

private void listConfig() {
    Log.i(TAG, "Config List {");
    for (EGLConfig config : mEGLConfigs) {
        int d, s, r, g, b, a;
        // Expand on this logic to dump other attributes
        d = getConfigAttrib(config, EGL_DEPTH_SIZE);
        s = getConfigAttrib(config, EGL_STENCIL_SIZE);
        r = getConfigAttrib(config, EGL_RED_SIZE);
        g = getConfigAttrib(config, EGL_GREEN_SIZE);
        b = getConfigAttrib(config, EGL_BLUE_SIZE);
        a = getConfigAttrib(config, EGL_ALPHA_SIZE);
        Log.i(TAG, "    <d,s,r,g,b,a> = <" + d + "," + s + "," + r + "," + g + "," + b + "," + a + ">");
    }
    Log.i(TAG, "}");
}
Also used : EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Aggregations

EGLConfig (javax.microedition.khronos.egl.EGLConfig)42 EGLSurface (javax.microedition.khronos.egl.EGLSurface)20 EGL10 (javax.microedition.khronos.egl.EGL10)12 EGLDisplay (javax.microedition.khronos.egl.EGLDisplay)12 TargetApi (android.annotation.TargetApi)9 EGLContext (javax.microedition.khronos.egl.EGLContext)8 SuppressLint (android.annotation.SuppressLint)1 Paint (android.graphics.Paint)1 TextPaint (android.text.TextPaint)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1