android.opengl.GLES10 Java Examples

The following examples show how to use android.opengl.GLES10. 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: ShaderLoader.java    From unity-ads-android with Apache License 2.0 6 votes vote down vote up
public static int load(String code, int type) {
	int shader = GLES20.glCreateShader(type);
	GLES20.glShaderSource(shader, code);
	GLES20.glCompileShader(shader);

	final int[] status = new int[1];
	GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, status, 0);

	if (status[0] != GLES10.GL_TRUE) {
		DeviceLog.error("Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
		GLES20.glDeleteShader(shader);
		shader = 0;
	}

	return shader;
}
 
Example #2
Source File: CompressedTextureActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void load(GL10 gl) {
    int width = 128;
    int height = 128;
    Buffer image = createImage(width, height);
    ETC1Util.ETC1Texture etc1Texture = ETC1Util.compressTexture(image, width, height, 3, 3 * width);
    if (USE_STREAM_IO) {
        // Test the ETC1Util APIs for reading and writing compressed textures to I/O streams.
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ETC1Util.writeTexture(etc1Texture, bos);
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
                    GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, bis);
        } catch (IOException e) {
            Log.w(TAG, "Could not load texture: " + e);
        }
    } else {
        ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
                GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
    }
}
 
Example #3
Source File: Room.java    From BobEngine with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Gathers the vertex, texture, and index data for each GameObject in this
 * room and passes that information to openGL. Can be called from another
 * room's draw method to draw both rooms at once. If overridden, call
 * super.draw(gl).
 *
 * @param gl OpenGL ES 1.0 object to do pass drawing information to.
 */
public void draw(GL10 gl) {
	// Update camera
	gl.glMatrixMode(GLES10.GL_PROJECTION);
	gl.glLoadIdentity();
	gl.glOrthof(camLeft, camRight, camBottom, camTop, -1, 1);

	// Draw graphics
	gl.glMatrixMode(GLES10.GL_MODELVIEW);
	gl.glLoadIdentity();

	for (int l = 0; l < layers; l++) {
		for (int i = 0; i < renderables.size(); i++) {
			Renderable r = renderables.get(i);

			if (r.getGraphic() != null && r.getGraphic().shouldLoad()) {     // Load the graphic if needed
				getView().getGraphicsHelper().addGraphic(r.getGraphic());
			}

			r.render(gl, l);
		}
	}
}
 
Example #4
Source File: EGLBase10.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * Viewportを設定
 * ここで設定した値は次回以降makeCurrentを呼んだときに復帰される
 * @param x
 * @param y
 * @param width
 * @param height
 */
@Override
public void setViewPort(final int x, final int y, final int width, final int height) {
	viewPortX = x;
	viewPortY = y;
	viewPortWidth = width;
	viewPortHeight = height;

	final int glVersion = mEglBase.getGlVersion();
	if (glVersion >= 3) {
		GLES30.glViewport(x, y, width, height);
	} else if (mEglBase.getGlVersion() >= 2) {
		GLES20.glViewport(x, y, width, height);
	} else {
		GLES10.glViewport(x, y, width, height);
	}
}
 
Example #5
Source File: EGLBase14.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * Viewportを設定
 * ここで設定した値は次回以降makeCurrentを呼んだときに復帰される
 * @param x
 * @param y
 * @param width
 * @param height
 */
@Override
public void setViewPort(final int x, final int y, final int width, final int height) {
	viewPortX = x;
	viewPortY = y;
	viewPortWidth = width;
	viewPortHeight = height;

	final int glVersion = mEglBase.getGlVersion();
	if (glVersion >= 3) {
		GLES30.glViewport(x, y, width, height);
	} else if (mEglBase.getGlVersion() >= 2) {
		GLES20.glViewport(x, y, width, height);
	} else {
		GLES10.glViewport(x, y, width, height);
	}
}
 
Example #6
Source File: GPU.java    From DeviceInfo with Apache License 2.0 6 votes vote down vote up
@Override
            protected void loadOnCreate() {
//                GL_RENDERER = glGetString(GLES10.GL_RENDERER);
//                GL_VERSION = glGetString(GLES10.GL_VERSION);
//                GL_VENDOR = glGetString(GLES10.GL_VENDOR);
                GL_MAX_TEXTURE_SIZE = glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE);
//                GL_MAX_TEXTURE_UNITS = glGetIntegerv(GLES10.GL_MAX_TEXTURE_UNITS);
//                GL_MAX_LIGHTS = glGetIntegerv(GLES10.GL_MAX_LIGHTS);
//                GL_SUBPIXEL_BITS = glGetIntegerv(GLES10.GL_SUBPIXEL_BITS);
//                GL_MAX_ELEMENTS_VERTICES = glGetIntegerv(GLES10.GL_MAX_ELEMENTS_VERTICES);
//                GL_MAX_ELEMENTS_INDICES = glGetIntegerv(GLES10.GL_MAX_ELEMENTS_INDICES);
//                GL_MAX_MODELVIEW_STACK_DEPTH = glGetIntegerv(GLES10.GL_MAX_MODELVIEW_STACK_DEPTH);
//                GL_MAX_PROJECTION_STACK_DEPTH = glGetIntegerv(GLES10.GL_MAX_PROJECTION_STACK_DEPTH);
//                GL_MAX_TEXTURE_STACK_DEPTH = glGetIntegerv(GLES10.GL_MAX_TEXTURE_STACK_DEPTH);
//                GL_DEPTH_BITS = glGetIntegerv(GLES10.GL_DEPTH_BITS);
//                GL_STENCIL_BITS = glGetIntegerv(GLES10.GL_STENCIL_BITS);
                GL_EXTENSIONS = glGetString(GLES10.GL_EXTENSIONS);
//                GL_MAX_VIEWPORT_DIMS = glGetIntegerv(GLES10.GL_MAX_VIEWPORT_DIMS, 2);
            }
 
Example #7
Source File: DeviceConfiguration.java    From android_packages_apps_GmsCore with Apache License 2.0 6 votes vote down vote up
private static void addExtensionsForConfig(EGL10 egl10, EGLDisplay egldisplay, EGLConfig eglconfig, int ai[],
                                           int ai1[], Set<String> set) {
    EGLContext eglcontext = egl10.eglCreateContext(egldisplay, eglconfig, EGL10.EGL_NO_CONTEXT, ai1);
    if (eglcontext != EGL10.EGL_NO_CONTEXT) {
        javax.microedition.khronos.egl.EGLSurface eglsurface =
                egl10.eglCreatePbufferSurface(egldisplay, eglconfig, ai);
        if (eglsurface == EGL10.EGL_NO_SURFACE) {
            egl10.eglDestroyContext(egldisplay, eglcontext);
        } else {
            egl10.eglMakeCurrent(egldisplay, eglsurface, eglsurface, eglcontext);
            String s = GLES10.glGetString(7939);
            if (s != null && !s.isEmpty()) {
                String as[] = s.split(" ");
                int i = as.length;
                for (int j = 0; j < i; j++) {
                    set.add(as[j]);
                }

            }
            egl10.eglMakeCurrent(egldisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
            egl10.eglDestroySurface(egldisplay, eglsurface);
            egl10.eglDestroyContext(egldisplay, eglcontext);
        }
    }
}
 
Example #8
Source File: EglExtensionRetriever.java    From YalpStore with GNU General Public License v2.0 6 votes vote down vote up
private static void addExtensionsForConfig(EGL10 egl10, EGLDisplay egldisplay, EGLConfig eglconfig, int ai[], int ai1[], Set<String> set) {
    EGLContext eglContext = egl10.eglCreateContext(egldisplay, eglconfig, EGL10.EGL_NO_CONTEXT, ai1);
    if (eglContext == EGL10.EGL_NO_CONTEXT) {
        return;
    }
    javax.microedition.khronos.egl.EGLSurface eglSurface = egl10.eglCreatePbufferSurface(egldisplay, eglconfig, ai);
    if (eglSurface == EGL10.EGL_NO_SURFACE) {
        egl10.eglDestroyContext(egldisplay, eglContext);
    } else {
        egl10.eglMakeCurrent(egldisplay, eglSurface, eglSurface, eglContext);
        String s = GLES10.glGetString(7939);
        if (!TextUtils.isEmpty(s)) {
            String as[] = s.split(" ");
            int i = as.length;
            for (int j = 0; j < i; j++) {
                set.add(as[j]);
            }
        }
        egl10.eglMakeCurrent(egldisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
        egl10.eglDestroySurface(egldisplay, eglSurface);
        egl10.eglDestroyContext(egldisplay, eglContext);
    }
}
 
Example #9
Source File: Utility.java    From BlackLight with GNU General Public License v3.0 6 votes vote down vote up
public static int getSupportedMaxPictureSize() {
	int[] array = new int[1];
	GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, array, 0);
	
	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);
			}
		}
	}
	
	return array[0] != 0 ? array[0] : 2048;
}
 
Example #10
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getMaxLeftWidthOrHeightImageViewCanRead(int heightOrWidth) {
    // 1pixel==4bytes
    // http://stackoverflow.com/questions/13536042/android-bitmap-allocating-16-bytes-per-pixel
    // http://stackoverflow.com/questions/15313807/android-maximum-allowed-width-height-of-bitmap
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    int maxHeight = maxSizeArray[0];
    int maxWidth = maxSizeArray[0];

    return (maxHeight * maxWidth) / heightOrWidth;
}
 
Example #11
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getBitmapMaxWidthAndMaxHeight() {
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    // return maxSizeArray[0];
    return 2048;
}
 
Example #12
Source File: ImageUtils.java    From monolog-android with MIT License 5 votes vote down vote up
public static int getBitmapMaxWidthAndMaxHeight() {
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    // return maxSizeArray[0];
    return 2048;
}
 
Example #13
Source File: Utils.java    From Android-CropView with Apache License 2.0 5 votes vote down vote up
public static int getMaxSize() {
    int maxSize = SIZE_DEFAULT;
    int[] arr = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, arr, 0);
    if (arr[0] > 0) {
        maxSize = Math.min(arr[0], SIZE_LIMIT);
    }
    return maxSize;
}
 
Example #14
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getMaxLeftWidthOrHeightImageViewCanRead(int heightOrWidth) {
    // 1pixel==4bytes
    // http://stackoverflow.com/questions/13536042/android-bitmap-allocating-16-bytes-per-pixel
    // http://stackoverflow.com/questions/15313807/android-maximum-allowed-width-height-of-bitmap
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    int maxHeight = maxSizeArray[0];
    int maxWidth = maxSizeArray[0];

    return (maxHeight * maxWidth) / heightOrWidth;
}
 
Example #15
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getBitmapMaxWidthAndMaxHeight() {
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    // return maxSizeArray[0];
    return 2048;
}
 
Example #16
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getMaxLeftWidthOrHeightImageViewCanRead(int heightOrWidth) {
    // 1pixel==4bytes
    // http://stackoverflow.com/questions/13536042/android-bitmap-allocating-16-bytes-per-pixel
    // http://stackoverflow.com/questions/15313807/android-maximum-allowed-width-height-of-bitmap
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    int maxHeight = maxSizeArray[0];
    int maxWidth = maxSizeArray[0];

    return (maxHeight * maxWidth) / heightOrWidth;
}
 
Example #17
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getBitmapMaxWidthAndMaxHeight() {
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    // return maxSizeArray[0];
    return 2048;
}
 
Example #18
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getMaxLeftWidthOrHeightImageViewCanRead(int heightOrWidth) {
    // 1pixel==4bytes
    // http://stackoverflow.com/questions/13536042/android-bitmap-allocating-16-bytes-per-pixel
    // http://stackoverflow.com/questions/15313807/android-maximum-allowed-width-height-of-bitmap
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    int maxHeight = maxSizeArray[0];
    int maxWidth = maxSizeArray[0];

    return (maxHeight * maxWidth) / heightOrWidth;
}
 
Example #19
Source File: SampleSizeUtil.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public static final int getTextureSize() {
	if (textureSize > 0) {
		return textureSize;
	}
	
	int[] params = new int[1];
	GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, params, 0);
	textureSize = params[0];
	
	return textureSize;		
}
 
Example #20
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getBitmapMaxWidthAndMaxHeight() {
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    // return maxSizeArray[0];
    return 2048;
}
 
Example #21
Source File: SampleSizeUtil.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
public static final int getTextureSize() {
    if (textureSize > 0) {
        return textureSize;
    }

    int[] params = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, params, 0);
    textureSize = params[0];

    return textureSize;
}
 
Example #22
Source File: Utils.java    From SimpleCropView with MIT License 5 votes vote down vote up
public static int getMaxSize() {
  int maxSize = SIZE_DEFAULT;
  int[] arr = new int[1];
  GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, arr, 0);
  if (arr[0] > 0) {
    maxSize = Math.min(arr[0], SIZE_LIMIT);
  }
  return maxSize;
}
 
Example #23
Source File: GOSurfaceView.java    From settlers-remake with MIT License 4 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
	GLES10.glClear(GLES10.GL_DEPTH_BUFFER_BIT | GLES10.GL_COLOR_BUFFER_BIT);
	area.drawArea(drawcontext);
}
 
Example #24
Source File: Points.java    From tango-ar-navigation-example with MIT License 4 votes vote down vote up
public void preRender() {
    super.preRender();
    setDrawingMode(GLES20.GL_POINTS);
    GLES10.glPointSize(5.0f);
}
 
Example #25
Source File: CropImageActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
private int getMaxTextureSize() {
    // The OpenGL texture size is the maximum size that can be drawn in an ImageView
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
    return maxSize[0];
}
 
Example #26
Source File: CropImageActivity.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
private int getMaxTextureSize() {
    // The OpenGL texture size is the maximum size that can be drawn in an ImageView
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
    return maxSize[0];
}
 
Example #27
Source File: SketchUtils.java    From sketch with Apache License 2.0 4 votes vote down vote up
private static int getOpenGLMaxTextureSizeBase() {
    // In JELLY_BEAN will collapse
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) {
        return 0;
    }

    EGL10 egl = (EGL10) EGLContext.getEGL();

    EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    int[] vers = new int[2];
    egl.eglInitialize(dpy, vers);

    int[] configAttr = {
            EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RGB_BUFFER,
            EGL10.EGL_LEVEL, 0,
            EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
            EGL10.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfig = new int[1];
    egl.eglChooseConfig(dpy, configAttr, configs, 1, numConfig);
    //noinspection StatementWithEmptyBody
    if (numConfig[0] == 0) {
        // TROUBLE! No config found.
    }
    EGLConfig config = configs[0];

    int[] surfAttr = new int[]{
            EGL10.EGL_WIDTH, 64,
            EGL10.EGL_HEIGHT, 64,
            EGL10.EGL_NONE
    };
    EGLSurface surf = egl.eglCreatePbufferSurface(dpy, config, surfAttr);
    final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;  // missing in EGL10
    int[] ctxAttrib = {
            EGL_CONTEXT_CLIENT_VERSION, 1,
            EGL10.EGL_NONE
    };
    EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, ctxAttrib);
    egl.eglMakeCurrent(dpy, surf, surf, ctx);
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GLES10.GL_MAX_TEXTURE_SIZE, maxSize, 0);

    egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    egl.eglDestroySurface(dpy, surf);
    egl.eglDestroyContext(dpy, ctx);
    egl.eglTerminate(dpy);

    return maxSize[0];
}
 
Example #28
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void renderMesh(Mesh mesh, int lod, int count) {
        if (context.pointSize != mesh.getPointSize()) {

            if (verboseLogging) {
                logger.log(Level.INFO, "GLES10.glPointSize({0})", mesh.getPointSize());
            }

            GLES10.glPointSize(mesh.getPointSize());
            context.pointSize = mesh.getPointSize();
        }
        if (context.lineWidth != mesh.getLineWidth()) {

            if (verboseLogging) {
                logger.log(Level.INFO, "GLES20.glLineWidth({0})", mesh.getLineWidth());
            }

            GLES20.glLineWidth(mesh.getLineWidth());
            context.lineWidth = mesh.getLineWidth();
        }

        statistics.onMeshDrawn(mesh, lod);
//        if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
//            renderMeshVertexArray(mesh, lod, count);
//        }else{

        if (useVBO) {
            if (verboseLogging) {
                logger.info("RENDERING A MESH USING VertexBufferObject");
            }

            renderMeshDefault(mesh, lod, count);
        } else {
            if (verboseLogging) {
                logger.info("RENDERING A MESH USING VertexArray");
            }

            renderMeshVertexArray(mesh, lod, count);
        }

//        }
    }
 
Example #29
Source File: GPU.java    From DeviceInfo with Apache License 2.0 4 votes vote down vote up
public synchronized static int glGetIntegerv(int value) {
    buffer.clear();
    GLES10.glGetIntegerv(value, buffer);
    return buffer.get(0);
}
 
Example #30
Source File: ActivityManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Adds all supported GL extensions for a provided EGLConfig to a set by creating an EGLContext
 * and EGLSurface and querying extensions.
 *
 * @param egl An EGL API object
 * @param display An EGLDisplay to create a context and surface with
 * @param config The EGLConfig to get the extensions for
 * @param surfaceSize eglCreatePbufferSurface generic parameters
 * @param contextAttribs eglCreateContext generic parameters
 * @param glExtensions A Set<String> to add GL extensions to
 */
private static void addExtensionsForConfig(
        EGL10 egl,
        EGLDisplay display,
        EGLConfig config,
        int[] surfaceSize,
        int[] contextAttribs,
        Set<String> glExtensions) {
    // Create a context.
    EGLContext context =
            egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, contextAttribs);
    // No-op if we can't create a context.
    if (context == EGL10.EGL_NO_CONTEXT) {
        return;
    }

    // Create a surface.
    EGLSurface surface = egl.eglCreatePbufferSurface(display, config, surfaceSize);
    if (surface == EGL10.EGL_NO_SURFACE) {
        egl.eglDestroyContext(display, context);
        return;
    }

    // Update the current surface and context.
    egl.eglMakeCurrent(display, surface, surface, context);

    // Get the list of extensions.
    String extensionList = GLES10.glGetString(GLES10.GL_EXTENSIONS);
    if (!TextUtils.isEmpty(extensionList)) {
        // The list of extensions comes from the driver separated by spaces.
        // Split them apart and add them into a Set for deduping purposes.
        for (String extension : extensionList.split(" ")) {
            glExtensions.add(extension);
        }
    }

    // Tear down the context and surface for this config.
    egl.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    egl.eglDestroySurface(display, surface);
    egl.eglDestroyContext(display, context);
}