Java Code Examples for javax.microedition.khronos.egl.EGL10#eglInitialize()
The following examples show how to use
javax.microedition.khronos.egl.EGL10#eglInitialize() .
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: EGL.java From video-player with MIT License | 6 votes |
public void start() { mEgl = (EGL10) EGLContext.getEGL(); mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } int[] version = new int[2]; if (!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } mEglSurface = null; }
Example 2
Source File: EGL.java From HPlayer with Apache License 2.0 | 6 votes |
public void start() { mEgl = (EGL10) EGLContext.getEGL(); mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } int[] version = new int[2]; if (!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } mEglSurface = null; }
Example 3
Source File: EGL.java From MyHearts with Apache License 2.0 | 6 votes |
public void start() { mEgl = (EGL10) EGLContext.getEGL(); mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } int[] version = new int[2]; if (!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } mEglSurface = null; }
Example 4
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 5
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 6
Source File: PixelBuffer.java From Fatigue-Detection with MIT License | 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 7
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 8
Source File: EglHelper.java From android-openGL-canvas with Apache License 2.0 | 4 votes |
/** * Initialize EGL for a given configuration spec. * @param eglContext */ @Override public EglContextWrapper start(EglContextWrapper eglContext) { FileLogger.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if (!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } mEglConfig = eglConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = eglContextFactory.createContext(mEgl, mEglDisplay, mEglConfig, eglContext.getEglContextOld()); if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } FileLogger.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); mEglSurface = null; EglContextWrapper eglContextWrapper = new EglContextWrapper(); eglContextWrapper.setEglContextOld(mEglContext); return eglContextWrapper; }
Example 9
Source File: GLTextureView.java From MusicPlayer with GNU General Public License v3.0 | 4 votes |
/** * Initialize EGL for a given configuration spec. * @param */ public void start() { if (LOG_EGL) { Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); } /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if(!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } GLTextureView view = mGLSurfaceViewWeakRef.get(); if (view == null) { mEglConfig = null; mEglContext = null; } else { mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); } if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } if (LOG_EGL) { Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); } mEglSurface = null; }
Example 10
Source File: OutputSurface.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void eglSetup(int width, int height) { mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL10 display"); } if (!mEGL.eglInitialize(mEGLDisplay, null)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL10"); } int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) { throw new RuntimeException("unable to find RGB888+pbuffer EGL config"); } int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } int[] surfaceAttribs = { EGL10.EGL_WIDTH, width, EGL10.EGL_HEIGHT, height, EGL10.EGL_NONE }; mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 11
Source File: GLTextureView.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 4 votes |
/** * Initialize EGL for a given configuration spec. * @param configSpec */ public void start() { if (LOG_EGL) { Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); } /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if(!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } GLTextureView view = mGLTextureViewWeakRef.get(); if (view == null) { mEglConfig = null; mEglContext = null; } else { mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); } if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } if (LOG_EGL) { Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); } mEglSurface = null; }
Example 12
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 13
Source File: OutputSurface.java From deltachat-android with GNU General Public License v3.0 | 4 votes |
private void eglSetup(int width, int height) { mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL10 display"); } if (!mEGL.eglInitialize(mEGLDisplay, null)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL10"); } int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) { throw new RuntimeException("unable to find RGB888+pbuffer EGL config"); } int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } int[] surfaceAttribs = { EGL10.EGL_WIDTH, width, EGL10.EGL_HEIGHT, height, EGL10.EGL_NONE }; mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 14
Source File: GLSurfaceView.java From unity-ads-android with Apache License 2.0 | 4 votes |
public void start() { if (LOG_EGL) { Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); } /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if(!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } GLSurfaceView view = mGLSurfaceViewWeakRef.get(); if (view == null) { mEglConfig = null; mEglContext = null; } else { mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); } if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } if (LOG_EGL) { Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); } mEglSurface = null; }
Example 15
Source File: GLTextureView.java From MD360Player4Android with Apache License 2.0 | 4 votes |
/** * Initialize EGL for a given configuration spec. * @param configSpec */ public void start() { if (LOG_EGL) { Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); } /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if(!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } GLTextureView view = mGLTextureViewWeakRef.get(); if (view == null) { mEglConfig = null; mEglContext = null; } else { mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); } if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } if (LOG_EGL) { Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); } mEglSurface = null; }
Example 16
Source File: GLTextureView.java From alpha-movie with Apache License 2.0 | 4 votes |
/** * Initialize EGL for a given configuration spec. * @param */ public void start() { if (LOG_EGL) { Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); } /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if(!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } GLTextureView view = mGLSurfaceViewWeakRef.get(); if (view == null) { mEglConfig = null; mEglContext = null; } else { mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); } if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } if (LOG_EGL) { Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); } mEglSurface = null; }
Example 17
Source File: GLTextureView.java From ZGDanmaku with Apache License 2.0 | 4 votes |
/** * Initialize EGL for a given configuration spec. * @param configSpec */ public void start() { if (LOG_EGL) { Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId()); } /* * Get an EGL instance */ mEgl = (EGL10) EGLContext.getEGL(); /* * Get to the default display. */ mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if(!mEgl.eglInitialize(mEglDisplay, version)) { throw new RuntimeException("eglInitialize failed"); } GLTextureView view = mGLTextureViewWeakRef.get(); if (view == null) { mEglConfig = null; mEglContext = null; } else { mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); /* * Create an EGL context. We want to do this as rarely as we can, because an * EGL context is a somewhat heavy object. */ mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig); } if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } if (LOG_EGL) { Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId()); } mEglSurface = null; }
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 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; } }
Example 20
Source File: OutputSurface.java From talk-android with MIT License | 4 votes |
private void eglSetup(int width, int height) { mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL10 display"); } if (!mEGL.eglInitialize(mEGLDisplay, null)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL10"); } int[] attribList = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!mEGL.eglChooseConfig(mEGLDisplay, attribList, configs, configs.length, numConfigs)) { throw new RuntimeException("unable to find RGB888+pbuffer EGL config"); } int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; mEGLContext = mEGL.eglCreateContext(mEGLDisplay, configs[0], EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } int[] surfaceAttribs = { EGL10.EGL_WIDTH, width, EGL10.EGL_HEIGHT, height, EGL10.EGL_NONE }; mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }