Java Code Examples for javax.microedition.khronos.egl.EGL10#eglMakeCurrent()
The following examples show how to use
javax.microedition.khronos.egl.EGL10#eglMakeCurrent() .
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: DeviceConfiguration.java From android_packages_apps_GmsCore with Apache License 2.0 | 6 votes |
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 2
Source File: EglExtensionRetriever.java From YalpStore with GNU General Public License v2.0 | 6 votes |
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 3
Source File: SimpleFPSDisplay.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 4
Source File: TextureGL.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 5
Source File: SimpleFPSDisplay.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 6
Source File: BasicGL.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 7
Source File: PixelBuffer.java From SimpleVideoEditor with Apache License 2.0 | 5 votes |
public PixelBuffer(final int width, final int height) { mWidth = width; mHeight = height; int[] version = new int[2]; int[] attribList = new int[] { EGL_WIDTH, mWidth, EGL_HEIGHT, mHeight, EGL_NONE }; // No error checking performed, minimum required code to elucidate logic mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY); mEGL.eglInitialize(mEGLDisplay, version); mEGLConfig = chooseConfig(); // Choosing a config is a little more // complicated // mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, // EGL_NO_CONTEXT, null); int EGL_CONTEXT_CLIENT_VERSION = 0x3098; int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, attrib_list); mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList); mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); mGL = (GL10) mEGLContext.getGL(); // Record thread owner of OpenGL context mThreadOwner = Thread.currentThread().getName(); }
Example 8
Source File: SimpleLitGLCube.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 9
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 10
Source File: BasicGLCube.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 11
Source File: BasicGL.java From opengl with Apache License 2.0 | 5 votes |
public void initEGL() { mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD, null); mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); int[] curGLVersion = new int[2]; mEGL.eglInitialize(mGLDisplay, curGLVersion); Log.i("GL", "GL version = " + curGLVersion[0] + "." + curGLVersion[1]); EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, 1, num_config); mGLConfig = configs[0]; mGLSurface = mEGL.eglCreateWindowSurface(mGLDisplay, mGLConfig, sv .getHolder(), null); mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig, EGL10.EGL_NO_CONTEXT, null); mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext); mGL = (GL10) GLDebugHelper.wrap(mGLContext.getGL(), GLDebugHelper.CONFIG_CHECK_GL_ERROR | GLDebugHelper.CONFIG_CHECK_THREAD | GLDebugHelper.CONFIG_LOG_ARGUMENT_NAMES, null); }
Example 12
Source File: PixelBuffer.java From DeviceConnect-Android with MIT License | 5 votes |
public PixelBuffer(final int width, final int height, final boolean isStereo) { mWidth = isStereo ? width * 2 : width; mHeight = height; mIb = IntBuffer.allocate(mWidth * mHeight); mBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888); mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY); int[] version = new int[2]; mEGL.eglInitialize(mEGLDisplay, version); mEGLConfigs = chooseConfigs(); mEGLConfig = mEGLConfigs[0]; mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, new int[] { 0x3098, // EGL_CONTEXT_CLIENT_VERSION 2, // OpenGL ES 2.0 EGL10.EGL_NONE }); mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, new int[] { EGL_WIDTH, mWidth, EGL_HEIGHT, mHeight, EGL_NONE }); mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); mGL = (GL10) mEGLContext.getGL(); mThreadOwner = Thread.currentThread().getName(); }
Example 13
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 14
Source File: myGLTextureView.java From opengl with Apache License 2.0 | 4 votes |
private void initGL() { mEgl = (EGL10) EGLContext.getEGL(); mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed " + GLUtils.getEGLErrorString(mEgl.eglGetError())); } int[] version = new int[2]; if (!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed " + GLUtils.getEGLErrorString(mEgl.eglGetError())); } int[] configsCount = new int[1]; EGLConfig[] configs = new EGLConfig[1]; int[] configSpec = { EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 16, //was 0 EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE }; eglConfig = null; if (!mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1, configsCount)) { throw new IllegalArgumentException( "eglChooseConfig failed " + GLUtils.getEGLErrorString(mEgl .eglGetError())); } else if (configsCount[0] > 0) { eglConfig = configs[0]; } if (eglConfig == null) { throw new RuntimeException("eglConfig not initialized"); } int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; mEglContext = mEgl.eglCreateContext(mEglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError(); mEglSurface = mEgl.eglCreateWindowSurface( mEglDisplay, eglConfig, mSurface, null); checkEglError(); if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) { int error = mEgl.eglGetError(); if (error == EGL10.EGL_BAD_NATIVE_WINDOW) { Log.e(TAG, "eglCreateWindowSurface returned EGL10.EGL_BAD_NATIVE_WINDOW"); return; } throw new RuntimeException( "eglCreateWindowSurface failed " + GLUtils.getEGLErrorString(error)); } if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) { throw new RuntimeException("eglMakeCurrent failed " + GLUtils.getEGLErrorString(mEgl.eglGetError())); } checkEglError(); mGl = (GL10) mEglContext.getGL(); checkEglError(); }
Example 15
Source File: GLRender.java From LiveBlurListView with Apache License 2.0 | 4 votes |
public GLRender(int width, int height) { int[] version = new int[2]; EGLConfig[] configs = new EGLConfig[1]; int[] num_config = new int[1]; int[] configSpec ={ EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_NONE }; int attribListPbuffer[] = { EGL10.EGL_WIDTH, width, EGL10.EGL_HEIGHT, height, EGL10.EGL_NONE }; mEgl = (EGL10)EGLContext.getEGL(); mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); mEgl.eglInitialize(mEglDisplay, version); mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1, num_config); EGLConfig mEglConfig = configs[0]; mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig, EGL10.EGL_NO_CONTEXT, null); if (mEglContext == EGL10.EGL_NO_CONTEXT) { Log.d(TAG, "EGL_NO_CONTEXT"); } mEglPBSurface = mEgl.eglCreatePbufferSurface(mEglDisplay, mEglConfig, attribListPbuffer); if (mEglPBSurface == EGL10.EGL_NO_SURFACE) { int errorcode = mEgl.eglGetError(); switch(errorcode) { case EGL10.EGL_BAD_DISPLAY: Log.d(TAG, "EGL_BAD_DISPLAY"); break; case EGL10.EGL_NOT_INITIALIZED: Log.d(TAG, "EGL_NOT_INITIALIZED"); break; case EGL10.EGL_BAD_CONFIG: Log.d(TAG, "EGL_BAD_CONFIG"); break; case EGL10.EGL_BAD_ATTRIBUTE: Log.d(TAG, "EGL_BAD_ATTRIBUTE"); break; case EGL10.EGL_BAD_ALLOC: Log.d(TAG, "EGL_BAD_ALLOC"); break; case EGL10.EGL_BAD_MATCH: Log.d(TAG, "EGL_BAD_MATCH"); break; } } if (!mEgl.eglMakeCurrent(mEglDisplay, mEglPBSurface, mEglPBSurface, mEglContext)) { Log.d(TAG, "bind failed code:" + mEgl.eglGetError()); } mGL = (GL10) mEglContext.getGL(); PixelBuffer = IntBuffer.allocate(width * height); }
Example 16
Source File: SketchUtils.java From sketch with Apache License 2.0 | 4 votes |
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 17
Source File: RenderView.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private boolean initGL() { egl10 = (EGL10) EGLContext.getEGL(); eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL10.EGL_NO_DISPLAY) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglGetDisplay failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } int[] version = new int[2]; if (!egl10.eglInitialize(eglDisplay, version)) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglInitialize failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } int[] configsCount = new int[1]; EGLConfig[] configs = new EGLConfig[1]; int[] configSpec = new int[]{ EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE }; EGLConfig eglConfig; if (!egl10.eglChooseConfig(eglDisplay, configSpec, configs, 1, configsCount)) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglChooseConfig failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } else if (configsCount[0] > 0) { eglConfig = configs[0]; } else { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglConfig not initialized"); } finish(); return false; } int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; eglContext = egl10.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); if (eglContext == null) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglCreateContext failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } if (surfaceTexture instanceof SurfaceTexture) { eglSurface = egl10.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceTexture, null); } else { finish(); return false; } if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) { if (BuildVars.LOGS_ENABLED) { FileLog.e("createWindowSurface failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { if (BuildVars.LOGS_ENABLED) { FileLog.e("eglMakeCurrent failed " + GLUtils.getEGLErrorString(egl10.eglGetError())); } finish(); return false; } GLES20.glEnable(GLES20.GL_BLEND); GLES20.glDisable(GLES20.GL_DITHER); GLES20.glDisable(GLES20.GL_STENCIL_TEST); GLES20.glDisable(GLES20.GL_DEPTH_TEST); painting.setupShaders(); checkBitmap(); painting.setBitmap(bitmap); Utils.HasGLError(); return true; }
Example 18
Source File: VisualizerRenderer.java From MusicVisualization with Apache License 2.0 | 4 votes |
private boolean initGL(SurfaceTexture texture) { mEgl10 = (EGL10) EGLContext.getEGL(); mEglDisplay = mEgl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) return false; int[] version = new int[2]; if (!mEgl10.eglInitialize(mEglDisplay, version)) return false; int[] configsCount = new int[1]; EGLConfig[] configs = new EGLConfig[1]; int[] configSpec = { EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE }; EGLConfig eglConfig = null; if (!mEgl10.eglChooseConfig(mEglDisplay, configSpec, configs, 1, configsCount)) { return false; } else if (configsCount[0] > 0) { eglConfig = configs[0]; } if (eglConfig == null) return false; mEglContext = mEgl10.eglCreateContext( mEglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, new int[]{EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}); mEglSurface = mEgl10.eglCreateWindowSurface(mEglDisplay, eglConfig, texture, null); if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) return false; if (!mEgl10.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) return false; return true; }
Example 19
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 20
Source File: ActivityManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * 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); }