Java Code Examples for android.opengl.EGL14#eglCreateContext()
The following examples show how to use
android.opengl.EGL14#eglCreateContext() .
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: EglBase14Impl.java From webrtc_android with MIT License | 6 votes |
private static EGLContext createEglContext( EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { if (sharedContext != null && sharedContext == EGL14.EGL_NO_CONTEXT) { throw new RuntimeException("Invalid sharedContext"); } int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE}; EGLContext rootContext = sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext; final EGLContext eglContext; synchronized (EglBase.lock) { eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0); } if (eglContext == EGL14.EGL_NO_CONTEXT) { throw new RuntimeException( "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError())); } return eglContext; }
Example 2
Source File: EglBase14.java From UltraGpuImage with MIT License | 6 votes |
private static EGLContext createEglContext( @Nullable EglBase14.Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { if (sharedContext != null && sharedContext.egl14Context == EGL14.EGL_NO_CONTEXT) { throw new RuntimeException("Invalid sharedContext"); } int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE}; EGLContext rootContext = sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context; final EGLContext eglContext; synchronized (EglBase.lock) { eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0); } if (eglContext == EGL14.EGL_NO_CONTEXT) { throw new RuntimeException( "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError())); } return eglContext; }
Example 3
Source File: EGLBase14.java From libcommon with Apache License 2.0 | 5 votes |
private EGLContext createContext(final Context sharedContext, final EGLConfig config, final int version) { if (DEBUG) Log.v(TAG, "createContext:version=" + version); final int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, version, EGL14.EGL_NONE }; final EGLContext context = EGL14.eglCreateContext(mEglDisplay, config, sharedContext.eglContext, attrib_list, 0); // checkEglError("eglCreateContext"); return context; }
Example 4
Source File: EGLBase.java From Fatigue-Detection with MIT License | 5 votes |
private EGLContext createContext(final EGLContext shared_context) { // if (DEBUG) Log.v(TAG, "createContext:"); final int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; final EGLContext context = EGL14.eglCreateContext(mEglDisplay, mEglConfig, shared_context, attrib_list, 0); checkEglError("eglCreateContext"); return context; }
Example 5
Source File: EGLBase.java From CameraRecorder-android with MIT License | 5 votes |
private EGLContext createContext(final EGLContext shared_context) { // if (DEBUG) Log.v(TAG, "createContext:"); final int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; final EGLContext context = EGL14.eglCreateContext(eglDisplay, eglConfig, shared_context, attrib_list, 0); checkEglError("eglCreateContext"); return context; }
Example 6
Source File: GLThread.java From android-openGL-canvas with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override public android.opengl.EGLContext createContextAPI17(android.opengl.EGLDisplay display, android.opengl.EGLConfig eglConfig, android.opengl.EGLContext sharedContext) { int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, contextClientVersion, EGL14.EGL_NONE}; return EGL14.eglCreateContext(display, eglConfig, sharedContext, attrib_list, 0); }
Example 7
Source File: SurfaceTextureRenderer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void configureEGLContext() { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new IllegalStateException("No EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, /*offset*/ 0, version, /*offset*/ 1)) { throw new IllegalStateException("Cannot initialize EGL14"); } int[] attribList = { EGL14.EGL_RED_SIZE, EGL_COLOR_BITLENGTH, EGL14.EGL_GREEN_SIZE, EGL_COLOR_BITLENGTH, EGL14.EGL_BLUE_SIZE, EGL_COLOR_BITLENGTH, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT | EGL14.EGL_WINDOW_BIT, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; EGL14.eglChooseConfig(mEGLDisplay, attribList, /*offset*/ 0, configs, /*offset*/ 0, configs.length, numConfigs, /*offset*/ 0); checkEglError("eglCreateContext RGB888+recordable ES2"); mConfigs = configs[0]; int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, /*offset*/ 0); checkEglError("eglCreateContext"); if(mEGLContext == EGL14.EGL_NO_CONTEXT) { throw new IllegalStateException("No EGLContext could be made"); } }
Example 8
Source File: EGLBase.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
private EGLContext createContext(final EGLContext shared_context) { final int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; final EGLContext context = EGL14.eglCreateContext(mEglDisplay, mEglConfig, shared_context, attrib_list, 0); checkEglError("eglCreateContext"); return context; }
Example 9
Source File: EGLBase.java From UVCCameraZxing with Apache License 2.0 | 5 votes |
private EGLContext createContext(final EGLContext shared_context) { // if (DEBUG) Log.v(TAG, "createContext:"); final int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; final EGLContext context = EGL14.eglCreateContext(mEglDisplay, mEglConfig, shared_context, attrib_list, 0); checkEglError("eglCreateContext"); return context; }
Example 10
Source File: EGLBase.java From MegviiFacepp-Android-SDK with Apache License 2.0 | 5 votes |
private EGLContext createContext(final EGLContext shared_context) { // if (DEBUG) Log.v(TAG, "createContext:"); final int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; final EGLContext context = EGL14.eglCreateContext(mEglDisplay, mEglConfig, shared_context, attrib_list, 0); checkEglError("eglCreateContext"); return context; }
Example 11
Source File: GLSurfaceView2.java From java6-android-glframework with Mozilla Public License 2.0 | 4 votes |
public EGLContext createContext(EGLDisplay display, EGLConfig config) { // If minor version is specified then use EGL_CONTEXT_MAJOR_VERSION_KHR / EGL_CONTEXT_MINOR_VERSION_KHR // otherwise use EGL_CONTEXT_CLIENT_VERSION int majorGLVersion = eglContextGLESVersion.getMajorVersion(); int minorGLVersion = eglContextGLESVersion.getMinorVersion(); int majorMinorAttribList[] = new int[]{ EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, majorGLVersion, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, minorGLVersion, EGL14.EGL_NONE }; int majorAttribList[] = new int[]{ EGL14.EGL_CONTEXT_CLIENT_VERSION, majorGLVersion, EGL14.EGL_NONE }; EGLContext context = null; if (minorGLVersion != 0) { context = EGL14.eglCreateContext(display, config, EGL14.EGL_NO_CONTEXT, majorGLVersion != 0 ? majorMinorAttribList : null, 0); } if (context == null || context.equals(EGL14.EGL_NO_CONTEXT)) { Log.d(s_TAG, "DefaultContextFactory - createContext: Could create requested context: " +eglContextGLESVersion); Log.d(s_TAG, "DefaultContextFactory - createContest: " + "Attempting to create context based on major GLES version: " +majorGLVersion); context = EGL14.eglCreateContext(display, config, EGL14.EGL_NO_CONTEXT, majorGLVersion != 0 ? majorAttribList : null, 0); minorGLVersion = 0; } int clientValue[] = new int[1]; EGL14.eglQueryContext(display, context, EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, clientValue, 0); if (EGL14.eglGetError() != EGL14.EGL_BAD_ATTRIBUTE) { majorGLVersion = clientValue[0]; } EGL14.eglQueryContext(display, context, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, clientValue, 0); if (EGL14.eglGetError() != EGL14.EGL_BAD_ATTRIBUTE) { minorGLVersion = clientValue[0]; } GLSurfaceView2.this.actualEGLContextGLESVersion = AndroidGLESUtil.getGLVersion(majorGLVersion, minorGLVersion); return context; }
Example 12
Source File: InputSurface.java From VideoCompressor with Apache License 2.0 | 4 votes |
private void eglSetup() { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } int[] surfaceAttribs = { EGL14.EGL_NONE }; mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 13
Source File: ExtractMpegFramesTest_egl14.java From Android-MediaCodec-Examples with Apache License 2.0 | 4 votes |
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports pbuffer. */ private void eglSetup() { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for pbuffer and OpenGL ES 2.0, 24-bit RGB. int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_ALPHA_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a pbuffer surface. int[] surfaceAttribs = { EGL14.EGL_WIDTH, mWidth, EGL14.EGL_HEIGHT, mHeight, EGL14.EGL_NONE }; mEGLSurface = EGL14.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs, 0); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 14
Source File: InputSurface.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void eglSetup() { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } int[] surfaceAttribs = { EGL14.EGL_NONE }; mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 15
Source File: Converter.java From VidEffects with Apache License 2.0 | 4 votes |
private void initEgl(Surface inputSurface) { eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL14.EGL_NO_DISPLAY) { Log.e(TAG, "eglDisplay == EGL14.EGL_NO_DISPLAY: " + GLUtils.getEGLErrorString(EGL14.eglGetError())); } int[] version = new int[2]; int[] attrsList = new int[]{ EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_ALPHA_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] ctxAttrs = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; int[] surfaceAttrs = { EGL14.EGL_NONE }; if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { Log.e(TAG, "eglInitialize: " + GLUtils.getEGLErrorString(EGL14.eglGetError())); } if (!EGL14.eglChooseConfig(eglDisplay, attrsList, 0, configs, 0, configs.length, new int[configs.length], 0)) { Log.e(TAG, GLUtils.getEGLErrorString(EGL14.eglGetError())); } eglContext = EGL14.eglCreateContext(eglDisplay, configs[0], EGL14.EGL_NO_CONTEXT, ctxAttrs, 0); eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, configs[0], inputSurface, surfaceAttrs, 0); if (!EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { Log.d(TAG, "eglMakeCurrent: " + GLUtils.getEGLErrorString(EGL14.eglGetError())); } }
Example 16
Source File: InputSurface.java From SimpleVideoEditor with Apache License 2.0 | 4 votes |
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording. */ private void eglSetup() { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for pbuffer and OpenGL ES 2.0. We want enough RGB bits // to be able to tell if the frame is reasonable. int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a window surface, and attach it to the Surface we received. int[] surfaceAttribs = { EGL14.EGL_NONE }; mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 17
Source File: EglUtil.java From SimpleVideoEditor with Apache License 2.0 | 4 votes |
/** * Returns a new GL ES context for the specified display, config and version. */ static EGLContext createEglContext(EGLDisplay eglDisplay, EGLConfig eglConfig, int version) { int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, version, EGL14.EGL_NONE}; return EGL14.eglCreateContext(eglDisplay, eglConfig, EGL14.EGL_NO_CONTEXT, contextAttributes, 0); }
Example 18
Source File: VideoRenderOutputSurface.java From LiTr with BSD 2-Clause "Simplified" License | 4 votes |
private void eglSetup() { eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { eglDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for recordable and OpenGL ES 2.0. We want enough RGB bits // to minimize artifacts from possible YUV conversion. int[] egl14ConfigAttributes = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(eglDisplay, egl14ConfigAttributes, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } // Configure context for OpenGL ES 2.0. int[] egl14ContextAttributes = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; eglContext = EGL14.eglCreateContext(eglDisplay, configs[0], EGL14.EGL_NO_CONTEXT, egl14ContextAttributes, 0); checkEglError("eglCreateContext"); if (eglContext == null) { throw new RuntimeException("null context"); } // Create a window surface, and attach it to the Surface we received. int[] surfaceAttribs = { EGL14.EGL_NONE }; eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, configs[0], surface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); if (eglSurface == null) { throw new RuntimeException("surface was null"); } }
Example 19
Source File: InputSurface.java From android-transcoder with Apache License 2.0 | 4 votes |
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording. */ private void eglSetup() { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for recordable and OpenGL ES 2.0. We want enough RGB bits // to minimize artifacts from possible YUV conversion. int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a window surface, and attach it to the Surface we received. int[] surfaceAttribs = { EGL14.EGL_NONE }; mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
Example 20
Source File: OutputSurface.java From phoenix with Apache License 2.0 | 4 votes |
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports pbuffer. */ private void eglSetup(int width, int height) { mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for pbuffer and OpenGL ES 2.0. We want enough RGB bits // to be able to tell if the frame is reasonable. int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_SURFACE_TYPE, EGL14.EGL_PBUFFER_BIT, EGL14.EGL_NONE }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a pbuffer surface. By using this for output, we can use glReadPixels // to test values in the output. int[] surfaceAttribs = { EGL14.EGL_WIDTH, width, EGL14.EGL_HEIGHT, height, EGL14.EGL_NONE }; mEGLSurface = EGL14.eglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs, 0); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }