Beispiel #1
0
            /**
             * Checks for EGL errors.
             */
            private void checkEglError(String msg)
            {
                int error;

                if ((error = EGL14.EglGetError()) != EGL14.EglSuccess)
                {
                    throw new RuntimeException(msg + ": EGL error: 0x" + Integer.ToHexString(error));
                }
            }
Beispiel #2
0
 public void DetachCurrent()
 {
     lock (EglBase.Lock)
     {
         if (!EGL14.EglMakeCurrent(_eglDisplay, EGL14.EglNoSurface, EGL14.EglNoSurface, EGL14.EglNoContext))
         {
             throw new RuntimeException("eglDetachCurrent failed: 0x" +
                                        Integer.ToHexString(EGL14.EglGetError()));
         }
     }
 }
        /**
         * Checks for EGL errors.
         */
        private void CheckEglError(string msg)
        {
            bool failed = false;
            int  error;

            while ((error = EGL14.EglGetError()) != EGL14.EglSuccess)
            {
                Log.Error(TAG, msg + ": EGL error: 0x" + Integer.ToHexString(error));
                failed = true;
            }

            if (failed)
            {
                throw new RuntimeException("EGL error encountered (see log)");
            }
        }
Beispiel #4
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 #5
0
            public void MakeCurrent()
            {
                CheckIsNotReleased();
                if (_eglSurface == EGL14.EglNoSurface)
                {
                    throw new RuntimeException("No EGLSurface - can't make current");
                }

                lock (EglBase.Lock)
                {
                    if (!EGL14.EglMakeCurrent(_eglDisplay, _eglSurface, _eglSurface, _eglContext))
                    {
                        throw new RuntimeException("eglMakeCurrent failed: 0x" +
                                                   Integer.ToHexString(EGL14.EglGetError()));
                    }
                }
            }
            private void CreateSurfaceInternal(Java.Lang.Object surface)
            {
                CheckIsNotReleased();
                if (_eglSurface != EGL14.EglNoSurface)
                {
                    throw new RuntimeException("Already has an EGLSurface");
                }

                var surfaceAttribs = new[] { 12344 };

                _eglSurface = EGL14.EglCreateWindowSurface(_eglDisplay, _eglConfig, surface, surfaceAttribs, 0);
                if (_eglSurface == EGL14.EglNoSurface)
                {
                    throw new RuntimeException("Failed to create window surface: 0x" +
                                               Integer.ToHexString(EGL14.EglGetError()));
                }
            }
Beispiel #7
0
            private static EGLDisplay GetEglDisplay()
            {
                var eglDisplay = EGL14.EglGetDisplay(0);

                if (eglDisplay == EGL14.EglNoDisplay)
                {
                    throw new RuntimeException("Unable to get EGL14 display: 0x" +
                                               Integer.ToHexString(EGL14.EglGetError()));
                }

                var 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);
            }
Beispiel #8
0
            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);
            }
 private void CheckEglError()
 {
     Debug.Assert(EGL14.EglGetError() == EGL14.EglSuccess);
 }