Example usage for android.opengl GLES20 glGetIntegerv

List of usage examples for android.opengl GLES20 glGetIntegerv

Introduction

In this page you can find the example usage for android.opengl GLES20 glGetIntegerv.

Prototype

public static native void glGetIntegerv(int pname, int[] params, int offset);

Source Link

Usage

From source file:Main.java

/**
 * Gets the total number of texture units available
 *
 * @return//ww w.  j a v a2s  .c  o  m
 */
public static int getNumTextureUnits() {
    int[] numTextureUnits = new int[1];
    GLES20.glGetIntegerv(GLES20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, numTextureUnits, 0);
    return numTextureUnits[0];
}

From source file:Main.java

public static void checkGLError(String msg) {
    int error = GLES20.glGetError();
    if (error != GLES20.GL_NO_ERROR) {
        String str = msg + ": glError 0x" + Integer.toHexString(error);
        Log.e(TAG, str);//  ww  w . j a  va 2s.  c  o  m
        int values[] = new int[2];
        GLES20.glGetIntegerv(GLES20.GL_ARRAY_BUFFER_BINDING, values, 0);
        GLES20.glGetIntegerv(GLES20.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, values, 1);
        Log.e(TAG, "Current bound array buffer: " + values[0]);
        Log.e(TAG, "Current bound vertex attrib: " + values[1]);
        throw new RuntimeException(msg);
    }
}

From source file:Main.java

@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 };/*from   w w  w  . j a  v a 2s  .c o m*/
    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];
}

From source file:Main.java

@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 };/*  w ww. ja v  a 2  s .  co m*/
    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[] ctxAttribute = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
    EGLContext ctx = EGL14.eglCreateContext(dpy, config, EGL14.EGL_NO_CONTEXT, ctxAttribute, 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];
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static int getOpenGLMaxTextureSizeJB1() {
    // Then get a hold of the default display, and initialize.
    // This could get more complex if you have to deal with devices that could have multiple displays,
    // but will be sufficient for a typical phone/tablet:
    android.opengl.EGLDisplay dpy = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    int[] vers = new int[2];
    EGL14.eglInitialize(dpy, vers, 0, vers, 1);

    // Next, we need to find a config. Since we won't use this context for rendering,
    // the exact attributes aren't very critical:
    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 };/*from  w w w.  j a  v a 2  s  .co  m*/
    android.opengl.EGLConfig[] configs = new android.opengl.EGLConfig[1];
    int[] numConfig = new int[1];
    EGL14.eglChooseConfig(dpy, configAttr, 0, configs, 0, 1, numConfig, 0);
    //noinspection StatementWithEmptyBody
    if (numConfig[0] == 0) {
        // TROUBLE! No config found.
    }
    android.opengl.EGLConfig config = configs[0];

    // To make a context current, which we will need later,
    // you need a rendering surface, even if you don't actually plan to render.
    // To satisfy this requirement, create a small offscreen (Pbuffer) surface:
    int[] surfAttr = { EGL14.EGL_WIDTH, 64, EGL14.EGL_HEIGHT, 64, EGL14.EGL_NONE };
    android.opengl.EGLSurface surf = EGL14.eglCreatePbufferSurface(dpy, config, surfAttr, 0);

    // Next, create the context:
    int[] ctxAttrib = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
    android.opengl.EGLContext ctx = EGL14.eglCreateContext(dpy, config, EGL14.EGL_NO_CONTEXT, ctxAttrib, 0);

    // Ready to make the context current now:
    EGL14.eglMakeCurrent(dpy, surf, surf, ctx);

    // If all of the above succeeded (error checking was omitted), you can make your OpenGL calls now:
    int[] maxSize = new int[1];
    GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxSize, 0);

    // Once you're all done, you can tear down everything:
    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];
}

From source file:info.papdt.blacklight.support.Utility.java

public static int getSupportedMaxPictureSize() {
    int[] array = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, array, 0);

    try {/*from  w w  w.  j  a v a  2  s .c om*/
        if (array[0] == 0) {
            GLES11.glGetIntegerv(GLES11.GL_MAX_TEXTURE_SIZE, array, 0);

            if (array[0] == 0) {
                GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, array, 0);

                if (array[0] == 0) {
                    GLES30.glGetIntegerv(GLES30.GL_MAX_TEXTURE_SIZE, array, 0);
                }
            }
        }
    } catch (NoClassDefFoundError e) {
        // Ignore the exception
    }

    return array[0] != 0 ? array[0] : 2048;
}