Java Code Examples for javax.microedition.khronos.egl.EGL10#eglTerminate()
The following examples show how to use
javax.microedition.khronos.egl.EGL10#eglTerminate() .
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: ResizingSurfaceView.java From ExoMedia with Apache License 2.0 | 6 votes |
/** * Clears the frames from the current surface. This should only be called when * the implementing video view has finished playback or otherwise released * the surface */ @Override public void clearSurface() { try { EGL10 gl10 = (EGL10) EGLContext.getEGL(); EGLDisplay display = gl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); gl10.eglInitialize(display, null); EGLConfig[] configs = new EGLConfig[1]; gl10.eglChooseConfig(display, GL_CLEAR_CONFIG_ATTRIBUTES, configs, configs.length, new int[1]); EGLContext context = gl10.eglCreateContext(display, configs[0], EGL10.EGL_NO_CONTEXT, GL_CLEAR_CONTEXT_ATTRIBUTES); EGLSurface eglSurface = gl10.eglCreateWindowSurface(display, configs[0], this, new int[]{EGL10.EGL_NONE}); gl10.eglMakeCurrent(display, eglSurface, eglSurface, context); gl10.eglSwapBuffers(display, eglSurface); gl10.eglDestroySurface(display, eglSurface); gl10.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); gl10.eglDestroyContext(display, context); gl10.eglTerminate(display); } catch (Exception e) { Log.e(TAG, "Error clearing surface", e); } }
Example 2
Source File: GLConfiguration.java From document-viewer with GNU General Public License v3.0 | 6 votes |
public static void checkConfiguration() { final EGL10 egl = (EGL10) EGLContext.getEGL(); final EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("Your device cannot support EGL"); } final int[] version = new int[2]; if (!egl.eglInitialize(eglDisplay, version)) { throw new RuntimeException("Your device cannot support EGL"); } try { if (getConfigChooser().chooseConfig(egl, eglDisplay) == null) { throw new RuntimeException("Your device cannot support required GLES configuration"); } } catch (final Throwable th) { throw new RuntimeException("Your device cannot support required GLES configuration"); } finally { egl.eglTerminate(eglDisplay); } }
Example 3
Source File: TextureSizeUtils.java From Moment with GNU General Public License v3.0 | 5 votes |
public static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) maximumTextureSize = textureSize[0]; } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); }
Example 4
Source File: TextureVideoView.java From texturevideoview with Apache License 2.0 | 5 votes |
/** * Clears the surface texture by attaching a GL context and clearing it. * Code taken from <a href="http://stackoverflow.com/a/31582209">Hugo Gresse's answer on stackoverflow.com</a>. */ private void clearSurface() { if (mSurface == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { return; } EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); egl.eglInitialize(display, null); int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_RENDERABLE_TYPE, EGL10.EGL_WINDOW_BIT, EGL10.EGL_NONE, 0, // placeholder for recordable [@-3] EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; egl.eglChooseConfig(display, attribList, configs, configs.length, numConfigs); EGLConfig config = configs[0]; EGLContext context = egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, new int[]{ 12440, 2, EGL10.EGL_NONE }); EGLSurface eglSurface = egl.eglCreateWindowSurface(display, config, mSurface, new int[]{ EGL10.EGL_NONE }); egl.eglMakeCurrent(display, eglSurface, eglSurface, context); GLES20.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); egl.eglSwapBuffers(display, eglSurface); egl.eglDestroySurface(display, eglSurface); egl.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); egl.eglDestroyContext(display, context); egl.eglTerminate(display); }
Example 5
Source File: ImgHelper.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
public static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) maximumTextureSize = textureSize[0]; } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); }
Example 6
Source File: DeviceConfiguration.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
private static void addEglExtensions(Set<String> glExtensions) { EGL10 egl10 = (EGL10) EGLContext.getEGL(); if (egl10 != null) { EGLDisplay display = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); egl10.eglInitialize(display, new int[2]); int cf[] = new int[1]; if (egl10.eglGetConfigs(display, null, 0, cf)) { EGLConfig[] configs = new EGLConfig[cf[0]]; if (egl10.eglGetConfigs(display, configs, cf[0], cf)) { int[] a1 = new int[]{EGL10.EGL_WIDTH, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_HEIGHT, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_NONE}; int[] a2 = new int[]{12440, EGL10.EGL_PIXMAP_BIT, EGL10.EGL_NONE}; int[] a3 = new int[1]; for (int i = 0; i < cf[0]; i++) { egl10.eglGetConfigAttrib(display, configs[i], EGL10.EGL_CONFIG_CAVEAT, a3); if (a3[0] != EGL10.EGL_SLOW_CONFIG) { egl10.eglGetConfigAttrib(display, configs[i], EGL10.EGL_SURFACE_TYPE, a3); if ((1 & a3[0]) != 0) { egl10.eglGetConfigAttrib(display, configs[i], EGL10.EGL_RENDERABLE_TYPE, a3); if ((1 & a3[0]) != 0) { addExtensionsForConfig(egl10, display, configs[i], a1, null, glExtensions); } if ((4 & a3[0]) != 0) { addExtensionsForConfig(egl10, display, configs[i], a1, a2, glExtensions); } } } } } } egl10.eglTerminate(display); } }
Example 7
Source File: ResizingTextureView.java From ExoMedia with Apache License 2.0 | 5 votes |
/** * Clears the frames from the current surface. This should only be called when * the implementing video view has finished playback or otherwise released * the surface */ @Override public void clearSurface() { if (getSurfaceTexture() == null) { return; } try { EGL10 gl10 = (EGL10) EGLContext.getEGL(); EGLDisplay display = gl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); gl10.eglInitialize(display, null); EGLConfig[] configs = new EGLConfig[1]; gl10.eglChooseConfig(display, GL_CLEAR_CONFIG_ATTRIBUTES, configs, configs.length, new int[1]); EGLContext context = gl10.eglCreateContext(display, configs[0], EGL10.EGL_NO_CONTEXT, GL_CLEAR_CONTEXT_ATTRIBUTES); EGLSurface eglSurface = gl10.eglCreateWindowSurface(display, configs[0], getSurfaceTexture(), new int[]{EGL10.EGL_NONE}); gl10.eglMakeCurrent(display, eglSurface, eglSurface, context); gl10.eglSwapBuffers(display, eglSurface); gl10.eglDestroySurface(display, eglSurface); gl10.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); gl10.eglDestroyContext(display, context); gl10.eglTerminate(display); } catch (Exception e) { Log.e(TAG, "Error clearing surface", e); } }
Example 8
Source File: BitmapUtil.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public static int getMaxTextureSize() { final int MAX_ALLOWED_TEXTURE_SIZE = 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.min(maximumTextureSize, MAX_ALLOWED_TEXTURE_SIZE); }
Example 9
Source File: Utils.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
public static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) maximumTextureSize = textureSize[0]; } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); }
Example 10
Source File: BitmapUtil.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static int getMaxTextureSize() { final int MAX_ALLOWED_TEXTURE_SIZE = 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.min(maximumTextureSize, MAX_ALLOWED_TEXTURE_SIZE); }
Example 11
Source File: Utils.java From react-native-documentscanner-android with MIT License | 5 votes |
public static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) maximumTextureSize = textureSize[0]; } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); }
Example 12
Source File: EglUtils.java From PictureSelector with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private static int getMaxTextureEgl10() { EGL10 egl = (EGL10) javax.microedition.khronos.egl.EGLContext.getEGL(); javax.microedition.khronos.egl.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 }; javax.microedition.khronos.egl.EGLConfig[] configs = new javax.microedition.khronos.egl.EGLConfig[1]; int[] numConfig = new int[1]; egl.eglChooseConfig(dpy, configAttr, configs, 1, numConfig); if (numConfig[0] == 0) { return 0; } javax.microedition.khronos.egl.EGLConfig config = configs[0]; int[] surfAttr = { EGL10.EGL_WIDTH, 64, EGL10.EGL_HEIGHT, 64, EGL10.EGL_NONE }; javax.microedition.khronos.egl.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 }; javax.microedition.khronos.egl.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 13
Source File: OBVideoPlayer.java From GLEXP-Team-onebillion with Apache License 2.0 | 4 votes |
private void clearSurface(SurfaceTexture texture) { if(texture == null){ return; } EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); egl.eglInitialize(display, null); int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_RENDERABLE_TYPE, EGL10.EGL_WINDOW_BIT, EGL10.EGL_NONE, 0, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; egl.eglChooseConfig(display, attribList, configs, configs.length, numConfigs); EGLConfig config = configs[0]; EGLContext context = egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, new int[]{ 12440, 2, EGL10.EGL_NONE }); EGLSurface eglSurface = egl.eglCreateWindowSurface(display, config, texture, new int[]{ EGL10.EGL_NONE }); egl.eglMakeCurrent(display, eglSurface, eglSurface, context); GLES20.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); egl.eglSwapBuffers(display, eglSurface); egl.eglDestroySurface(display, eglSurface); egl.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); egl.eglDestroyContext(display, context); egl.eglTerminate(display); }
Example 14
Source File: BitmapUtils.java From timecat with Apache License 2.0 | 4 votes |
/** * Get the max size of bitmap allowed to be rendered on the device.<br> * http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit. */ private static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; try { // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) { maximumTextureSize = textureSize[0]; } } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); } catch (Exception e) { return IMAGE_MAX_BITMAP_DIMENSION; } }
Example 15
Source File: EglUtils.java From Matisse-Kotlin with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private static int getMaxTextureEgl10() { EGL10 egl = (EGL10) javax.microedition.khronos.egl.EGLContext.getEGL(); javax.microedition.khronos.egl.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 }; javax.microedition.khronos.egl.EGLConfig[] configs = new javax.microedition.khronos.egl.EGLConfig[1]; int[] numConfig = new int[1]; egl.eglChooseConfig(dpy, configAttr, configs, 1, numConfig); if (numConfig[0] == 0) { return 0; } javax.microedition.khronos.egl.EGLConfig config = configs[0]; int[] surfAttr = { EGL10.EGL_WIDTH, 64, EGL10.EGL_HEIGHT, 64, EGL10.EGL_NONE }; javax.microedition.khronos.egl.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 }; javax.microedition.khronos.egl.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 16
Source File: OGLESContext.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public GLSurfaceView createView(AndroidInput view, ConfigType configType, boolean eglConfigVerboseLogging, boolean antialias) { // Start to set up the view this.view = view; verboseLogging = eglConfigVerboseLogging; if (configType == ConfigType.LEGACY) { // Hardcoded egl setup clientOpenGLESVersion = 2; view.setEGLContextClientVersion(2); //RGB565, Depth16 // view.setEGLConfigChooser(5, 6, 5, 0, 16, 0); logger.info("ConfigType.LEGACY using RGB565"); view.setEGLConfigChooser(8, 8, 8, 8, 16, 0); view.getHolder().setFormat(PixelFormat.TRANSLUCENT); view.setZOrderOnTop(true); } else { EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] version = new int[2]; if (egl.eglInitialize(display, version) == true) { logger.info("Display EGL Version: " + version[0] + "." + version[1]); } // Create a config chooser AndroidConfigChooser configChooser = new AndroidConfigChooser(configType, eglConfigVerboseLogging, antialias); // Init chooser if (!configChooser.findConfig(egl, display)) { logger.severe("Unable to find suitable EGL config"); } clientOpenGLESVersion = configChooser.getClientOpenGLESVersion(); if (clientOpenGLESVersion < 2) { logger.severe("OpenGL ES 2.0 is not supported on this device"); } if (display != null) egl.eglTerminate(display); /* * Requesting client version from GLSurfaceView which is extended by * AndroidInput. */ view.setEGLContextClientVersion(clientOpenGLESVersion); // view.setEGLConfigChooser(configChooser); // view.getHolder().setFormat(configChooser.getPixelFormat()); view.setEGLConfigChooser(8, 8, 8, 8, 16, 0); view.getHolder().setFormat(PixelFormat.TRANSLUCENT); view.setZOrderOnTop(true); } view.setFocusableInTouchMode(true); view.setFocusable(true); view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); view.setRenderer(this); return view; }
Example 17
Source File: ActivityManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
Set<String> getGlExtensionsFromDriver() { Set<String> glExtensions = new HashSet<>(); // Get the EGL implementation. EGL10 egl = (EGL10) EGLContext.getEGL(); if (egl == null) { getErrPrintWriter().println("Warning: couldn't get EGL"); return glExtensions; } // Get the default display and initialize it. EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] version = new int[2]; egl.eglInitialize(display, version); // Call getConfigs() in order to find out how many there are. int[] numConfigs = new int[1]; if (!egl.eglGetConfigs(display, null, 0, numConfigs)) { getErrPrintWriter().println("Warning: couldn't get EGL config count"); return glExtensions; } // Allocate space for all configs and ask again. EGLConfig[] configs = new EGLConfig[numConfigs[0]]; if (!egl.eglGetConfigs(display, configs, numConfigs[0], numConfigs)) { getErrPrintWriter().println("Warning: couldn't get EGL configs"); return glExtensions; } // Allocate surface size parameters outside of the main loop to cut down // on GC thrashing. 1x1 is enough since we are only using it to get at // the list of extensions. int[] surfaceSize = new int[] { EGL10.EGL_WIDTH, 1, EGL10.EGL_HEIGHT, 1, EGL10.EGL_NONE }; // For when we need to create a GLES2.0 context. final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; int[] gles2 = new int[] {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; // For getting return values from eglGetConfigAttrib int[] attrib = new int[1]; for (int i = 0; i < numConfigs[0]; i++) { // Get caveat for this config in order to skip slow (i.e. software) configs. egl.eglGetConfigAttrib(display, configs[i], EGL10.EGL_CONFIG_CAVEAT, attrib); if (attrib[0] == EGL10.EGL_SLOW_CONFIG) { continue; } // If the config does not support pbuffers we cannot do an eglMakeCurrent // on it in addExtensionsForConfig(), so skip it here. Attempting to make // it current with a pbuffer will result in an EGL_BAD_MATCH error egl.eglGetConfigAttrib(display, configs[i], EGL10.EGL_SURFACE_TYPE, attrib); if ((attrib[0] & EGL10.EGL_PBUFFER_BIT) == 0) { continue; } final int EGL_OPENGL_ES_BIT = 0x0001; final int EGL_OPENGL_ES2_BIT = 0x0004; egl.eglGetConfigAttrib(display, configs[i], EGL10.EGL_RENDERABLE_TYPE, attrib); if ((attrib[0] & EGL_OPENGL_ES_BIT) != 0) { addExtensionsForConfig(egl, display, configs[i], surfaceSize, null, glExtensions); } if ((attrib[0] & EGL_OPENGL_ES2_BIT) != 0) { addExtensionsForConfig(egl, display, configs[i], surfaceSize, gles2, glExtensions); } } // Release all EGL resources. egl.eglTerminate(display); return glExtensions; }
Example 18
Source File: EglUtils.java From EasyPhotos with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private static int getMaxTextureEgl10() { EGL10 egl = (EGL10) javax.microedition.khronos.egl.EGLContext.getEGL(); javax.microedition.khronos.egl.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 }; javax.microedition.khronos.egl.EGLConfig[] configs = new javax.microedition.khronos.egl.EGLConfig[1]; int[] numConfig = new int[1]; egl.eglChooseConfig(dpy, configAttr, configs, 1, numConfig); if (numConfig[0] == 0) { return 0; } javax.microedition.khronos.egl.EGLConfig config = configs[0]; int[] surfAttr = { EGL10.EGL_WIDTH, 64, EGL10.EGL_HEIGHT, 64, EGL10.EGL_NONE }; javax.microedition.khronos.egl.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 }; javax.microedition.khronos.egl.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 19
Source File: BitmapUtils.java From giffun with Apache License 2.0 | 4 votes |
/** * Get the max size of bitmap allowed to be rendered on the device.<br> * http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit. */ private static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; try { // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib( display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) { maximumTextureSize = textureSize[0]; } } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); } catch (Exception e) { return IMAGE_MAX_BITMAP_DIMENSION; } }
Example 20
Source File: BitmapUtils.java From Lassi-Android with MIT License | 4 votes |
/** * Get the max size of bitmap allowed to be rendered on the device.<br> * http://stackoverflow.com/questions/7428996/hw-accelerated-activity-how-to-get-opengl-texture-size-limit. */ private static int getMaxTextureSize() { // Safe minimum default size final int IMAGE_MAX_BITMAP_DIMENSION = 2048; try { // Get EGL Display EGL10 egl = (EGL10) EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib( display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) { maximumTextureSize = textureSize[0]; } } // Release egl.eglTerminate(display); // Return largest texture size found, or default return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION); } catch (Exception e) { Logger.INSTANCE.e(logTag, "getMaxTextureSize >> " + e); return IMAGE_MAX_BITMAP_DIMENSION; } }