EGLConfig chooseEglConfig(EGLDisplay eglDisplay) { int[] configsCount = new int[] { 0 }; EGLConfig[] configs = new EGLConfig[1]; EGL14.EglChooseConfig(eglDisplay, config, 0, configs, 0, configs.Length, configsCount, 0); return configs[0]; }
private bool ElgInitialize() { prevEglContext = EGL14.EglGetCurrentContext(); prevEglDisplay = EGL14.EglGetCurrentDisplay(); prevEglSurfaceRead = EGL14.EglGetCurrentSurface(EGL14.EglRead); prevEglSurfaceDraw = EGL14.EglGetCurrentSurface(EGL14.EglDraw); eglDisplay = EGL14.EglGetDisplay(EGL14.EglDefaultDisplay); if (eglDisplay == EGL14.EglNoDisplay) { return(false); } int[] version = new int[2]; if (!EGL14.EglInitialize(eglDisplay, version, 0, version, 1)) { return(false); } // Configure EGL for recording and OpenGL ES 2.0. int[] attribList = { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglAlphaSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEsBit, EGL_RECORDABLE_ANDROID, 1, EGL14.EglNone }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; EGL14.EglChooseConfig(eglDisplay, attribList, 0, configs, 0, configs.Length, numConfigs, 0); CheckEglError(); // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EglContextClientVersion, 1, EGL14.EglNone }; eglContext = EGL14.EglCreateContext(eglDisplay, configs[0], EGL14.EglNoContext, attrib_list, 0); CheckEglError(); int[] surfaceAttribs = { EGL14.EglNone }; eglSurface = EGL14.EglCreateWindowSurface(eglDisplay, configs[0], surface, surfaceAttribs, 0); CheckEglError(); EGL14.EglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); CheckEglError(); return(true); }
private static EGLConfig GetEglConfig(EGLDisplay eglDisplay, int[] configAttributes) { var configs = new EGLConfig[1]; var numConfigs = new int[1]; if (!EGL14.EglChooseConfig(eglDisplay, configAttributes, 0, configs, 0, configs.Length, numConfigs, 0)) { throw new RuntimeException("eglChooseConfig failed: 0x" + Integer.ToHexString(EGL14.EglGetError())); } if (numConfigs[0] <= 0) { throw new RuntimeException("Unable to find any matching EGL config"); } EGLConfig eglConfig = configs[0]; if (eglConfig == null) { throw new RuntimeException("eglChooseConfig returned null"); } return(eglConfig); }
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports pbuffer. */ private void eglSetup() { mEGLDisplay = EGL14.EglGetDisplay(EGL14.EglDefaultDisplay); if (mEGLDisplay == EGL14.EglNoDisplay) { 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.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglAlphaSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEs2Bit, EGL14.EglSurfaceType, EGL14.EglPbufferBit, EGL14.EglNone }; 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.EglContextClientVersion, 2, EGL14.EglNone }; mEGLContext = EGL14.EglCreateContext(mEGLDisplay, configs[0], EGL14.EglNoContext, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a pbuffer surface. int[] surfaceAttribs = { EGL14.EglWidth, mWidth, EGL14.EglHeight, mHeight, EGL14.EglNone }; mEGLSurface = EGL14.EglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs, 0); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording. */ private void eglSetup() { mEGLDisplay = EGL14.EglGetDisplay(EGL14.EglDefaultDisplay); if (mEGLDisplay == EGL14.EglNoDisplay) { throw new Java.Lang.RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.EglInitialize(mEGLDisplay, version, 0, version, 1)) { throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for recording and OpenGL ES 2.0. int[] attribList; if (mEGLSharedContext == null) { attribList = new int[] { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEs2Bit, EGL14.EglNone }; } else { attribList = new int[] { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEs2Bit, EGL_RECORDABLE_ANDROID, 1, EGL14.EglNone }; } EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; EGL14.EglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.Length, numConfigs, 0); checkEglError("eglCreateContext RGB888+recordable ES2"); // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EglContextClientVersion, 2, EGL14.EglNone }; if (mEGLSharedContext == null) { mEGLContext = EGL14.EglCreateContext(mEGLDisplay, configs[0], EGL14.EglNoContext, attrib_list, 0); } else { mEGLContext = EGL14.EglCreateContext(mEGLDisplay, configs[0], mEGLSharedContext, attrib_list, 0); } checkEglError("eglCreateContext"); // Create a window surface, and attach it to the Surface we received. int[] surfaceAttribs = { EGL14.EglNone }; mEGLSurface = EGL14.EglCreateWindowSurface(mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); GLES20.GlDisable(GLES20.GlDepthTest); GLES20.GlDisable(GLES20.GlCullFaceMode); }
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording. */ private void EglSetup() { _EGLDisplay = EGL14.EglGetDisplay(EGL14.EglDefaultDisplay); if (_EGLDisplay == EGL14.EglNoDisplay) { 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 pbuffer and OpenGL ES 2.0. We want enough RGB bits // to be able to tell if the frame is reasonable. int[] attribList = { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglRenderableType, EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EglNone }; var configs = new EGLConfig[1]; var numConfigs = new int[1]; if (!EGL14.EglChooseConfig(_EGLDisplay, 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.EglContextClientVersion, 2, EGL14.EglNone }; _EGLContext = EGL14.EglCreateContext(_EGLDisplay, configs[0], EGL14.EglNoContext, attrib_list, 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.EglNone }; _EGLSurface = EGL14.EglCreateWindowSurface(_EGLDisplay, configs[0], _surface, surfaceAttribs, 0); CheckEglError("eglCreateWindowSurface"); if (_EGLSurface == null) { throw new RuntimeException("surface was null"); } }