Beispiel #1
0
            public void CreatePbufferSurface(int width, int height)
            {
                CheckIsNotReleased();
                if (_eglSurface != EGL14.EglNoSurface)
                {
                    throw new RuntimeException("Already has an EGLSurface");
                }

                var surfaceAttribs = new[] { 12375, width, 12374, height, 12344 };

                _eglSurface = EGL14.EglCreatePbufferSurface(_eglDisplay, _eglConfig, surfaceAttribs, 0);
                if (_eglSurface == EGL14.EglNoSurface)
                {
                    throw new RuntimeException("Failed to create pixel buffer surface with size " + width + "x" +
                                               height + ": 0x" + Integer.ToHexString(EGL14.EglGetError()));
                }
            }
Beispiel #2
0
            /**
             * 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");
                }
            }