Search in sources :

Example 1 with EGLContext

use of android.opengl.EGLContext in project uCrop by Yalantis.

the class EglUtils method getMaxTextureEgl14.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static int getMaxTextureEgl14() {
    EGLDisplay dpy = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    int[] vers = new int[2];
    EGL14.eglInitialize(dpy, vers, 0, vers, 1);
    int[] configAttr = { EGL14.EGL_COLOR_BUFFER_TYPE, EGL14.EGL_RGB_BUFFER, EGL14.EGL_LEVEL, 0, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT, EGL14.EGL_NONE };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfig = new int[1];
    EGL14.eglChooseConfig(dpy, configAttr, 0, configs, 0, 1, numConfig, 0);
    if (numConfig[0] == 0) {
        return 0;
    }
    EGLConfig config = configs[0];
    int[] surfAttr = { EGL14.EGL_WIDTH, 64, EGL14.EGL_HEIGHT, 64, EGL14.EGL_NONE };
    EGLSurface surf = EGL14.eglCreatePbufferSurface(dpy, config, surfAttr, 0);
    int[] ctxAttrib = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
    EGLContext ctx = EGL14.eglCreateContext(dpy, config, EGL14.EGL_NO_CONTEXT, ctxAttrib, 0);
    EGL14.eglMakeCurrent(dpy, surf, surf, ctx);
    int[] maxSize = new int[1];
    GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxSize, 0);
    EGL14.eglMakeCurrent(dpy, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
    EGL14.eglDestroySurface(dpy, surf);
    EGL14.eglDestroyContext(dpy, ctx);
    EGL14.eglTerminate(dpy);
    return maxSize[0];
}
Also used : EGLSurface(android.opengl.EGLSurface) EGLDisplay(android.opengl.EGLDisplay) EGLContext(android.opengl.EGLContext) EGLConfig(android.opengl.EGLConfig) TargetApi(android.annotation.TargetApi)

Example 2 with EGLContext

use of android.opengl.EGLContext in project grafika by google.

the class EglCore method logCurrent.

/**
     * Writes the current display, context, and surface to the log.
     */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;
    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context + ", surface=" + surface);
}
Also used : EGLSurface(android.opengl.EGLSurface) EGLDisplay(android.opengl.EGLDisplay) EGLContext(android.opengl.EGLContext)

Example 3 with EGLContext

use of android.opengl.EGLContext in project Reader by TheKeeperOfPie.

the class UtilsImage method checkMaxTextureSize.

/**
     * Ensures we know the OpenGL texture size limit. This is a hack.
     */
public static void checkMaxTextureSize(final Handler handler, final Runnable runnable) {
    if (MAX_TEXTURE_SIZE > 0) {
        runnable.run();
    } else {
        new Thread(new Runnable() {

            @Override
            public void run() {
                int[] numConfigs = new int[1];
                int[] configAttrs = { EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_ALPHA_SIZE, 0, EGL14.EGL_DEPTH_SIZE, 0, EGL14.EGL_STENCIL_SIZE, 0, EGL14.EGL_NONE };
                int[] contextAttrs = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
                int[] surfaceAttrs = { EGL14.EGL_WIDTH, 1, EGL14.EGL_HEIGHT, 1, EGL14.EGL_NONE };
                EGLConfig[] configs = new EGLConfig[1];
                EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
                EGL14.eglChooseConfig(eglDisplay, configAttrs, 0, configs, 0, 1, numConfigs, 0);
                EGLContext eglContext = EGL14.eglCreateContext(eglDisplay, configs[0], EGL14.EGL_NO_CONTEXT, contextAttrs, 0);
                EGLSurface eglSurface = EGL14.eglCreatePbufferSurface(eglDisplay, configs[0], surfaceAttrs, 0);
                EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
                int[] array = new int[1];
                GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, array, 0);
                Log.d(TAG, "calculateTextureSize() called with: " + array[0]);
                MAX_TEXTURE_SIZE = array[0];
                EGL14.eglDestroyContext(eglDisplay, eglContext);
                EGL14.eglDestroySurface(eglDisplay, eglSurface);
                EGL14.eglReleaseThread();
                handler.post(runnable);
            }
        }).start();
    }
}
Also used : EGLSurface(android.opengl.EGLSurface) EGLDisplay(android.opengl.EGLDisplay) EGLContext(android.opengl.EGLContext) EGLConfig(android.opengl.EGLConfig)

Example 4 with EGLContext

use of android.opengl.EGLContext in project Reader by TheKeeperOfPie.

the class UtilsImage method calculateTextureSize.

public static void calculateTextureSize() {
    new Thread(new Runnable() {

        @Override
        public void run() {
            int[] numConfigs = new int[1];
            int[] configAttrs = { EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_ALPHA_SIZE, 0, EGL14.EGL_DEPTH_SIZE, 0, EGL14.EGL_STENCIL_SIZE, 0, EGL14.EGL_NONE };
            int[] contextAttrs = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
            int[] surfaceAttrs = { EGL14.EGL_WIDTH, 1, EGL14.EGL_HEIGHT, 1, EGL14.EGL_NONE };
            EGLConfig[] configs = new EGLConfig[1];
            EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
            EGL14.eglChooseConfig(eglDisplay, configAttrs, 0, configs, 0, 1, numConfigs, 0);
            EGLContext eglContext = EGL14.eglCreateContext(eglDisplay, configs[0], EGL14.EGL_NO_CONTEXT, contextAttrs, 0);
            EGLSurface eglSurface = EGL14.eglCreatePbufferSurface(eglDisplay, configs[0], surfaceAttrs, 0);
            EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
            int[] array = new int[1];
            GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, array, 0);
            Log.d(TAG, "calculateTextureSize() called with: " + array[0]);
            MAX_TEXTURE_SIZE = array[0];
            EGL14.eglDestroyContext(eglDisplay, eglContext);
            EGL14.eglDestroySurface(eglDisplay, eglSurface);
            EGL14.eglTerminate(eglDisplay);
            EGL14.eglReleaseThread();
        }
    }).start();
}
Also used : EGLSurface(android.opengl.EGLSurface) EGLDisplay(android.opengl.EGLDisplay) EGLContext(android.opengl.EGLContext) EGLConfig(android.opengl.EGLConfig)

Example 5 with EGLContext

use of android.opengl.EGLContext in project MagicCamera by wuhaoyu1990.

the class EglCore method logCurrent.

/**
     * Writes the current display, context, and surface to the log.
     */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;
    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context + ", surface=" + surface);
}
Also used : EGLSurface(android.opengl.EGLSurface) EGLDisplay(android.opengl.EGLDisplay) EGLContext(android.opengl.EGLContext)

Aggregations

EGLContext (android.opengl.EGLContext)5 EGLDisplay (android.opengl.EGLDisplay)5 EGLSurface (android.opengl.EGLSurface)5 EGLConfig (android.opengl.EGLConfig)3 TargetApi (android.annotation.TargetApi)1