Java Code Examples for android.opengl.EGL14#eglGetDisplay()
The following examples show how to use
android.opengl.EGL14#eglGetDisplay() .
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: EGLBase.java From CameraRecorder-android with MIT License | 5 votes |
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) { if (DEBUG) Log.v(TAG, "init:"); if (eglDisplay != EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("EGL already set up"); } eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } final int[] version = new int[2]; if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { eglDisplay = null; throw new RuntimeException("eglInitialize failed"); } shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT; if (eglContext == EGL14.EGL_NO_CONTEXT) { eglConfig = getConfig(with_depth_buffer, isRecordable); if (eglConfig == null) { throw new RuntimeException("chooseConfig failed"); } // create EGL rendering context eglContext = createContext(shared_context); } // confirm whether the EGL rendering context is successfully created final int[] values = new int[1]; EGL14.eglQueryContext(eglDisplay, eglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0); if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]); makeDefault(); // makeCurrent(EGL14.EGL_NO_SURFACE); }
Example 2
Source File: EGLSurfaceTexture.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static EGLDisplay getDefaultDisplay() { EGLDisplay display = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (display == null) { throw new GlException("eglGetDisplay failed"); } int[] version = new int[2]; boolean eglInitialized = EGL14.eglInitialize(display, version, /* majorOffset= */ 0, version, /* minorOffset= */ 1); if (!eglInitialized) { throw new GlException("eglInitialize failed"); } return display; }
Example 3
Source File: EglBase14.java From UltraGpuImage with MIT License | 5 votes |
private static EGLDisplay getEglDisplay() { EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException( "Unable to get EGL14 display: 0x" + Integer.toHexString(EGL14.eglGetError())); } int[] version = new int[2]; if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { throw new RuntimeException( "Unable to initialize EGL14: 0x" + Integer.toHexString(EGL14.eglGetError())); } return eglDisplay; }
Example 4
Source File: EGLSurfaceTexture.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static EGLDisplay getDefaultDisplay() { EGLDisplay display = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (display == null) { throw new GlException("eglGetDisplay failed"); } int[] version = new int[2]; boolean eglInitialized = EGL14.eglInitialize(display, version, /* majorOffset= */ 0, version, /* minorOffset= */ 1); if (!eglInitialized) { throw new GlException("eglInitialize failed"); } return display; }
Example 5
Source File: InputSurface.java From AndroidVideoSamples with Apache License 2.0 | 5 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 6
Source File: EglBase14.java From VideoCRE with MIT License | 5 votes |
private static EGLDisplay getEglDisplay() { EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException( "Unable to get EGL14 display: 0x" + Integer.toHexString(EGL14.eglGetError())); } int[] version = new int[2]; if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { throw new RuntimeException( "Unable to initialize EGL14: 0x" + Integer.toHexString(EGL14.eglGetError())); } return eglDisplay; }
Example 7
Source File: EGLBase.java From In77Camera with MIT License | 5 votes |
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) { if (DEBUG) Log.v(TAG, "init:"); if (mEglDisplay != EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("EGL already set up"); } mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } final int[] version = new int[2]; if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) { mEglDisplay = null; throw new RuntimeException("eglInitialize failed"); } shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT; if (mEglContext == EGL14.EGL_NO_CONTEXT) { mEglConfig = getConfig(with_depth_buffer, isRecordable); if (mEglConfig == null) { throw new RuntimeException("chooseConfig failed"); } // create EGL rendering context mEglContext = createContext(shared_context); } // confirm whether the EGL rendering context is successfully created final int[] values = new int[1]; EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0); if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]); makeDefault(); // makeCurrent(EGL14.EGL_NO_SURFACE); }
Example 8
Source File: EGLBase.java From UVCCameraZxing with Apache License 2.0 | 5 votes |
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) { if (DEBUG) Log.v(TAG, "init:"); if (mEglDisplay != EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("EGL already set up"); } mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } final int[] version = new int[2]; if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) { mEglDisplay = null; throw new RuntimeException("eglInitialize failed"); } shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT; if (mEglContext == EGL14.EGL_NO_CONTEXT) { mEglConfig = getConfig(with_depth_buffer, isRecordable); if (mEglConfig == null) { throw new RuntimeException("chooseConfig failed"); } // create EGL rendering context mEglContext = createContext(shared_context); } // confirm whether the EGL rendering context is successfully created final int[] values = new int[1]; EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0); if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]); makeDefault(); // makeCurrent(EGL14.EGL_NO_SURFACE); }
Example 9
Source File: EGLBase.java From AudioVideoRecordingSample with Apache License 2.0 | 5 votes |
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) { if (DEBUG) Log.v(TAG, "init:"); if (mEglDisplay != EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("EGL already set up"); } mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } final int[] version = new int[2]; if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) { mEglDisplay = null; throw new RuntimeException("eglInitialize failed"); } shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT; if (mEglContext == EGL14.EGL_NO_CONTEXT) { mEglConfig = getConfig(with_depth_buffer, isRecordable); if (mEglConfig == null) { throw new RuntimeException("chooseConfig failed"); } // create EGL rendering context mEglContext = createContext(shared_context); } // confirm whether the EGL rendering context is successfully created final int[] values = new int[1]; EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0); if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]); makeDefault(); // makeCurrent(EGL14.EGL_NO_SURFACE); }
Example 10
Source File: OutputSurface.java From SimpleVideoEdit 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. // 这里的播放也用了888 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"); } }
Example 11
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 12
Source File: InputSurface.java From LiveMultimedia 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 13
Source File: OutputSurface.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 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"); } }
Example 14
Source File: InputSurface.java From deltachat-android with GNU General Public License v3.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: InputSurface.java From SiliCompressor 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 16
Source File: EglUtils.java From PictureSelector with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private static int getMaxTextureEgl14() { EGLDisplay dpy = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); int[] vers = new int[2]; EGL14.eglInitialize(dpy, vers, 0, vers, 1); int[] configAttr = { EGL14.EGL_COLOR_BUFFER_TYPE, EGL14.EGL_RGB_BUFFER, EGL14.EGL_LEVEL, 0, 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[] numConfig = new int[1]; EGL14.eglChooseConfig(dpy, configAttr, 0, configs, 0, 1, numConfig, 0); if (numConfig[0] == 0) { return 0; } EGLConfig config = configs[0]; int[] surfAttr = { EGL14.EGL_WIDTH, 64, EGL14.EGL_HEIGHT, 64, EGL14.EGL_NONE }; EGLSurface surf = EGL14.eglCreatePbufferSurface(dpy, config, surfAttr, 0); int[] ctxAttrib = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }; EGLContext ctx = EGL14.eglCreateContext(dpy, config, EGL14.EGL_NO_CONTEXT, ctxAttrib, 0); EGL14.eglMakeCurrent(dpy, surf, surf, ctx); int[] maxSize = new int[1]; GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxSize, 0); EGL14.eglMakeCurrent(dpy, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT); EGL14.eglDestroySurface(dpy, surf); EGL14.eglDestroyContext(dpy, ctx); EGL14.eglTerminate(dpy); return maxSize[0]; }
Example 17
Source File: EglHelperAPI17.java From DanDanPlayForAndroid with MIT License | 4 votes |
@Override public EglContextWrapper start(EglContextWrapper eglContext) { /* * Get an EGL instance */ /* * Get to the default display. */ mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (mEglDisplay == EGL14.EGL_NO_DISPLAY) { throw new RuntimeException("eglGetDisplay failed"); } /* * We can now initialize EGL for that display */ int[] version = new int[2]; if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) { mEglDisplay = null; throw new RuntimeException("eglInitialize failed"); } mEglConfig = eglConfigChooser.chooseConfig(mEglDisplay, false); /* * 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.createContextAPI17(mEglDisplay, mEglConfig, eglContext.getEglContext()); if (mEglContext == null || mEglContext == EGL14.EGL_NO_CONTEXT) { mEglContext = null; throwEglException("createContext"); } mEglSurface = null; EglContextWrapper eglContextWrapper = new EglContextWrapper(); eglContextWrapper.setEglContext(mEglContext); return eglContextWrapper; }
Example 18
Source File: InputSurface.java From TelePlus-Android 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 19
Source File: InputSurface.java From react-native-video-helper with MIT License | 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 20
Source File: EglManager.java From AudioVideoCodec with Apache License 2.0 | 4 votes |
/** * EGL配置步骤1-7 * * @param surface :surface * @param context :EGLContext */ public void init(Surface surface, EGLContext context) { eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL14.EGL_NO_DISPLAY) { Log.d(TAG, "获取显示设备失败 "); return; } int[] version = new int[2]; boolean isInit = EGL14.eglInitialize(eglDisplay, version, 0, version, 1); if (!isInit) { Log.d(TAG, "EGL14初始化失败"); return; } //参数配置以 id - value 格式组成 int[] attribute = new int[]{ EGL14.EGL_BUFFER_SIZE, 32,//颜色缓冲区所有组成颜色的位数 EGL14.EGL_ALPHA_SIZE, 8,//缓冲区透明度位数 EGL14.EGL_RED_SIZE, 8,//缓冲区红色位数 EGL14.EGL_BLUE_SIZE, 8,//缓冲区蓝色位数 EGL14.EGL_GREEN_SIZE, 8,//缓冲区绿色位数 EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,//渲染窗口支持的布局类型 EGL14.EGL_SURFACE_TYPE, EGL14.EGL_WINDOW_BIT,//EGL窗口支持的类型 EGL14.EGL_NONE//标识结尾信息 }; EGLConfig[] eglConfig = new EGLConfig[1]; int[] numConfigs = new int[1]; boolean isConfig = EGL14.eglChooseConfig(eglDisplay, attribute, 0, eglConfig, 0, eglConfig.length, numConfigs, 0); if (!isConfig || numConfigs[0] < 0) { Log.d(TAG, "config参数配置失败"); return; } //指定OpenGL ES 2.0版本 int[] contextAttribute = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE}; if (context == null) { eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig[0], EGL14.EGL_NO_CONTEXT, contextAttribute, 0); } else { //传入context,表示与其它OpenGL ES上下文共享资源 eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig[0], context, contextAttribute, 0); } if (eglContext == EGL14.EGL_NO_CONTEXT) { Log.d(TAG, "EGLContext 创建失败"); return; } int[] attrs = {EGL14.EGL_NONE}; eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, eglConfig[0], surface, attrs, 0); if (eglSurface == EGL14.EGL_NO_SURFACE) { Log.d(TAG, "连接EGL和设备屏幕失败"); return; } //绑定eglContext boolean isMakeCurrent = EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); if (!isMakeCurrent) { Log.d(TAG, "eglContext绑定失败"); } }