Пример #1
0
            public BackgroundContext(MonoGameAndroidGameView view)
            {
                _view = view ?? throw new ArgumentNullException(nameof(view));

                foreach (var v in OpenGL.GLESVersion.GetSupportedGLESVersions())
                {
                    _eglContext = view.egl.EglCreateContext(view.eglDisplay, view.eglConfig, EGL10.EglNoContext, v.GetAttributes());
                    if (_eglContext == null || _eglContext == EGL10.EglNoContext)
                    {
                        continue;
                    }
                    break;
                }

                if (_eglContext == null || _eglContext == EGL10.EglNoContext)
                {
                    _eglContext = null;
                    throw new Exception("Could not create EGL context" + view.GetErrorAsString());
                }

                var pbufferAttribList = new int[] { EGL10.EglWidth, 64, EGL10.EglHeight, 64, EGL10.EglNone };

                _surface = view.CreatePBufferSurface(view.eglConfig, pbufferAttribList);
                if (_surface == EGL10.EglNoSurface)
                {
                    throw new Exception("Could not create Pbuffer Surface" + view.GetErrorAsString());
                }
            }
Пример #2
0
            // called by ovrApp_HandleVrModeChanges
            public void ovrEgl_CreateSurface(native_window.ANativeWindow nativeWindow)
            {
                ConsoleExtensions.trace("enter ovrEgl_CreateSurface");

                //298
                if (this.MainSurface != egl.EGL_NO_SURFACE)
                {
                    return;
                }
                //ALOGV( "        MainSurface = eglCreateWindowSurface( Display, Config, nativeWindow, attribs )" );

                ConsoleExtensions.trace("ovrEgl_CreateSurface, eglCreateWindowSurface");

                this.MainSurface = egl.eglCreateWindowSurface(this.Display, this.Config, nativeWindow, eglCreateWindowSurface_surfaceAttribs);
                if (this.MainSurface == egl.EGL_NO_SURFACE)
                {
                    //ALOGE( "        eglCreateWindowSurface() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }

                ConsoleExtensions.trace("ovrEgl_CreateSurface, eglMakeCurrent");

                //ALOGV( "        eglMakeCurrent( display, MainSurface, MainSurface, Context )" );
                if (egl.eglMakeCurrent(this.Display, this.MainSurface, this.MainSurface, this.Context) == false)
                {
                    //ALOGE( "        eglMakeCurrent() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }

                ConsoleExtensions.trace("exit ovrEgl_CreateSurface, ready for ovrRenderer_Create");
            }
Пример #3
0
 public void ReleaseSurface()
 {
     if (_eglSurface != EGL14.EglNoSurface)
     {
         EGL14.EglDestroySurface(_eglDisplay, _eglSurface);
         _eglSurface = EGL14.EglNoSurface;
     }
 }
Пример #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (handle != IntPtr.Zero)
     {
         eglDestroySurface(ctx.dpy, handle);
     }
     handle = IntPtr.Zero;
 }
Пример #5
0
        private void DestroyRenderSurface()
        {
            if (mOpenGLES != null)
            {
                mOpenGLES.DestroySurface(mRenderSurface);
            }

            mRenderSurface = EGL.NO_SURFACE;
        }
Пример #6
0
 public Surface(Context _ctx, DRI.GBM.Surface gbmSurf)
 {
     ctx    = _ctx;
     handle = eglCreateWindowSurface(ctx.dpy, ctx.currentCfg, gbmSurf.handle, IntPtr.Zero);
     if (handle == IntPtr.Zero)
     {
         throw new NotSupportedException(String.Format("[EGL] Failed to create surface, error {0}.", EGL.Context.GetError()));
     }
 }
Пример #7
0
        Surface(Context _ctx, IntPtr config, int[] attrib_list)
        {
            ctx = _ctx;

            handle = eglCreatePbufferSurface(ctx.dpy, config, attrib_list);
            if (handle == IntPtr.Zero)
            {
                throw new NotSupportedException(String.Format("[EGL] Failed to create surface, error {0}.", EGL.Context.GetError()));
            }
        }
Пример #8
0
 private void DestroyEglSurface()
 {
     if (eglSurface != null)
     {
         if (!egl.EglDestroySurface(eglDisplay, eglSurface))
         {
             throw new System.Exception($"Could not destroy EGL surface, error {GetEglErrorString()}");
         }
         eglSurface = null;
     }
 }
Пример #9
0
        private void CreateEglSurface()
        {
            EnsureEglDisplayCreated();
            var surface = egl.EglCreateWindowSurface(eglDisplay, eglConfig, (Java.Lang.Object)Holder, null);

            if (surface == null || surface == EGL10.EglNoSurface)
            {
                throw new System.Exception($"Could not create EGL surface, error {GetEglErrorString()}");
            }
            eglSurface = surface;
        }
Пример #10
0
        protected EGLSurface CreatePBufferSurface(EGLConfig config, int[] attribList)
        {
            IEGL10     egl    = EGLContext.EGL.JavaCast <IEGL10>();
            EGLSurface result = egl.EglCreatePbufferSurface(eglDisplay, config, attribList);

            if (result == null || result == EGL10.EglNoSurface)
            {
                throw new Exception("EglCreatePBufferSurface");
            }
            return(result);
        }
Пример #11
0
            public EglBase14Impl(EGLContext sharedContext, int[] configAttributes)
            {
                _eglSurface = EGL14.EglNoSurface;
                _eglDisplay = GetEglDisplay();
                _eglConfig  = GetEglConfig(_eglDisplay, configAttributes);

                int openGlesVersion = GetOpenGlesVersionFromConfig(configAttributes);

                Logging.D("EglBase14Impl", "Using OpenGL ES version " + openGlesVersion);
                _eglContext = CreateEglContext(sharedContext, _eglDisplay, _eglConfig, openGlesVersion);
            }
Пример #12
0
        public EGLSurface CreatePBufferSurface(EGLConfig config, int[] attribList)
        {
            IEGL10     egl    = EGLContext.EGL.JavaCast <IEGL10> ();
            EGLSurface result = egl.EglCreatePbufferSurface(eglDisplay, config, attribList);

            if (result == null || result == EGL10.EglNoSurface)
            {
                throw EglException.GenerateException("EglCreatePBufferSurface", egl, null);
            }
            return(result);
        }
Пример #13
0
        void CustomSwap()
        {
            // Instead of letting the application call eglSwapBuffers, call eglPostSubBufferNV here instead
            int        windowWidth  = this.Width;
            int        windowHeight = this.Height;
            EGLDisplay display      = getGLControlDisplay();
            EGLSurface surface      = getGLSurface();

            //test drop draw target to (60,200) and resize
            mPostSubBufferNV(display, surface, 60, 200, windowWidth - 120, windowHeight - 120);
        }
Пример #14
0
        internal OpenGLESPage(OpenGLES openGLES)
        {
            mOpenGLES      = openGLES;
            mRenderSurface = EGL.NO_SURFACE;
            InitializeComponent();

            Windows.UI.Core.CoreWindow window = Windows.UI.Xaml.Window.Current.CoreWindow;

            window.VisibilityChanged += new TypedEventHandler <CoreWindow, VisibilityChangedEventArgs>((win, args) => OnVisibilityChanged(win, args));

            Loaded += (sender, args) => OnPageLoaded(sender, args);
        }
Пример #15
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);
        }
Пример #16
0
        internal GLUWPControl(OpenGLES openGLES, Func <RendererBase> rendererInit)
        {
            mOpenGLES      = openGLES;
            mRenderSurface = EGL.NO_SURFACE;
            RendererInit   = rendererInit;
            InitializeComponent();

            CoreWindow window = Window.Current.CoreWindow;

            window.VisibilityChanged += new TypedEventHandler <CoreWindow, VisibilityChangedEventArgs>((win, args) => OnVisibilityChanged(win, args));

            Loaded += (sender, args) => OnLoaded(sender, args);
        }
Пример #17
0
        public EGLConfig GetConfigFromDrawable(EGLSurface drawable, int width, int height)
        {
#warning CAN NOT CAST EGLCONFIG > INT[], how's that possible? :S
            throw new NotSupportedException();
            //EGLConfig glConfig = null;
            //if (!EGLCONTEXT.EGL11.EglQuerySurface(_glDisplay, drawable, Javax.Microedition.Khronos.Egl.EGL10Consts.EglConfigId, null))
            //{
            //    throw new AxiomException("Fail to get config from drawable");
            //}
            //EGLCONTEXT.EGL11.EglQuerySurface(_glDisplay, drawable, Javax.Microedition.Khronos.Egl.EGL10Consts.EglWidth, new int[] { width });
            //EGLCONTEXT.EGL11.EglQuerySurface(_glDisplay, drawable, Javax.Microedition.Khronos.Egl.EGL10Consts.EglHeight, new int[] { height });

            //return glConfig;
        }
Пример #18
0
        public void CreateSurface(EGLConfig config)
        {
            if (refHolder == null)
            {
                CreatePBufferSurface(config);
                return;
            }

            IEGL10 egl = EGLContext.EGL.JavaCast <IEGL10> ();

            eglSurface = egl.EglCreateWindowSurface(eglDisplay, config, ((Java.Lang.Object)Holder), null);
            if (eglSurface == null || eglSurface == EGL10.EglNoSurface)
            {
                throw EglException.GenerateException("EglCreateWindowSurface", egl, null);
            }
        }
 /**
  * Discards all resources held by this class, notably the EGL context.  Also releases the
  * Surface that was passed to our constructor.
  */
 public void release()
 {
     if (mEGLDisplay != EGL14.EglNoDisplay)
     {
         EGL14.EglMakeCurrent(mEGLDisplay, EGL14.EglNoSurface, EGL14.EglNoSurface,
                              EGL14.EglNoContext);
         EGL14.EglDestroySurface(mEGLDisplay, mEGLSurface);
         EGL14.EglDestroyContext(mEGLDisplay, mEGLContext);
         EGL14.EglReleaseThread();
         EGL14.EglTerminate(mEGLDisplay);
     }
     mEGLDisplay = EGL14.EglNoDisplay;
     mEGLContext = EGL14.EglNoContext;
     mEGLSurface = EGL14.EglNoSurface;
     mSurface.Release();
 }
Пример #20
0
            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()));
                }
            }
Пример #21
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()));
                }
            }
Пример #22
0
            private void Prepare()
            {
                mEglCore    = new EglCore();
                mEglSurface = mEglCore.CreateOffscreenSurface(1, 1);
                mEglCore.MakeCurrent(mEglSurface);
                mTextureId             = IO.Agora.Api.Component.Gles.Core.GlUtil.CreateTextureObject(GLES11Ext.GlTextureExternalOes);
                mSurfaceTexture        = new SurfaceTexture(mTextureId);
                mSurface               = new Surface(mSurfaceTexture);
                mThreadContext         = new GLThreadContext();
                mThreadContext.EglCore = mEglCore;
                mThreadContext.Context = mEglCore.EGLContext;
                mThreadContext.Program = new ProgramTextureOES();
                _externalVideoInputManager._textureTransformer = new TextureTransformer(MAX_TEXTURE_COPY);

                /**Customizes the video source.
                 * Call this method to add an external video source to the SDK.*/
                IO.Agora.Api.Component.Constant.Engine.SetVideoSource(_externalVideoInputManager);
            }
Пример #23
0
/*
 *              public void CreatePixmapSurface (EGLConfig config)
 *              {
 *                      Surface = egl.EglCreatePixmapSurface (Display, config, null ,null);
 *                      if (Surface == null || Surface == EGL10.EglNoSurface)
 *                              throw EglException.GenerateException ("EglCreatePixmapSurface", egl, null);
 *              }
 */
        public void DestroySurface()
        {
            if (eglSurface != EGL10.EglNoSurface)
            {
                IEGL10 egl = EGLContext.EGL.JavaCast <IEGL10> ();
                try     {
                    egl.EglMakeCurrent(eglDisplay, EGL10.EglNoSurface, EGL10.EglNoSurface, EGL10.EglNoContext);
                    if (!egl.EglDestroySurface(eglDisplay, eglSurface))
                    {
                        Log.Warn("AndroidWindow", "Failed to destroy surface {0}.", eglSurface);
                    }
                }
                catch (Java.Lang.IllegalArgumentException)      {
                    Log.Warn("AndroidWindow", "Failed to destroy surface {0}. Illegal Argument", eglSurface);
                }
                eglSurface = null;
            }
        }
Пример #24
0
        public void ElgShutdown()
        {
            if (eglDisplay != EGL14.EglNoDisplay)
            {
                EGL14.EglMakeCurrent(eglDisplay, EGL14.EglNoSurface, EGL14.EglNoSurface, EGL14.EglNoContext);
                EGL14.EglDestroySurface(eglDisplay, eglSurface);
                EGL14.EglDestroyContext(eglDisplay, eglContext);
                EGL14.EglReleaseThread();
                EGL14.EglTerminate(eglDisplay);
            }

            surface.Release();

            eglDisplay = EGL14.EglNoDisplay;
            eglContext = EGL14.EglNoContext;
            eglSurface = EGL14.EglNoSurface;

            surface = null;

            EGL14.EglMakeCurrent(prevEglDisplay, prevEglSurfaceDraw, prevEglSurfaceRead, prevEglContext);
        }
Пример #25
0
 // called by ovrApp_Clear
 public void ovrEgl_DestroySurface()
 {
     // 320
     if (this.Context != egl.EGL_NO_CONTEXT)
     {
         //ALOGV("        eglMakeCurrent( display, TinySurface, TinySurface, Context )");
         if (egl.eglMakeCurrent(this.Display, this.TinySurface, this.TinySurface, this.Context) == false)
         {
             //ALOGE("        eglMakeCurrent() failed: %s", EglErrorString(eglGetError()));
         }
     }
     if (this.MainSurface != egl.EGL_NO_SURFACE)
     {
         //ALOGV("        eglDestroySurface( Display, MainSurface )");
         if (egl.eglDestroySurface(this.Display, this.MainSurface) == false)
         {
             //ALOGE("        eglDestroySurface() failed: %s", EglErrorString(eglGetError()));
         }
         this.MainSurface = egl.EGL_NO_SURFACE;
     }
 }
Пример #26
0
        /**
         * Discard all resources held by this class, notably the EGL context. Also releases the
         * Surface that was passed to our constructor.
         */
        public void Release()
        {
            if (EGL14.EglGetCurrentContext().Equals(_EGLContext))
            {
                // Clear the current context and surface to ensure they are discarded immediately.
                EGL14.EglMakeCurrent(_EGLDisplay, EGL14.EglNoSurface, EGL14.EglNoSurface,
                                     EGL14.EglNoContext);
            }

            EGL14.EglDestroySurface(_EGLDisplay, _EGLSurface);
            EGL14.EglDestroyContext(_EGLDisplay, _EGLContext);

            //EGL14.eglTerminate(mEGLDisplay);
            _surface.Release();

            // null everything out so future attempts to use this object will cause an NPE
            _EGLDisplay = null;
            _EGLContext = null;
            _EGLSurface = null;
            _surface    = null;
        }
Пример #27
0
            // called by AppThreadFunction
            public void ovrEgl_DestroyContext()
            {
                // 259

                if (this.Display != egl.EGL_NO_DISPLAY)
                {
                    //ALOGE("        eglMakeCurrent( Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )");
                    if (egl.eglMakeCurrent(this.Display, egl.EGL_NO_SURFACE, egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT) == false)
                    {
                        //ALOGE("        eglMakeCurrent() failed: %s", EglErrorString(eglGetError()));
                    }
                }
                if (this.Context != egl.EGL_NO_CONTEXT)
                {
                    //ALOGE("        eglDestroyContext( Display, Context )");
                    if (egl.eglDestroyContext(this.Display, this.Context) == false)
                    {
                        //ALOGE("        eglDestroyContext() failed: %s", EglErrorString(eglGetError()));
                    }
                    this.Context = egl.EGL_NO_CONTEXT;
                }
                if (this.TinySurface != egl.EGL_NO_SURFACE)
                {
                    //ALOGE("        eglDestroySurface( Display, TinySurface )");
                    if (egl.eglDestroySurface(this.Display, this.TinySurface) == false)
                    {
                        //ALOGE("        eglDestroySurface() failed: %s", EglErrorString(eglGetError()));
                    }
                    this.TinySurface = egl.EGL_NO_SURFACE;
                }
                if (this.Display != egl.EGL_NO_DISPLAY)
                {
                    //ALOGE("        eglTerminate( Display )");
                    if (egl.eglTerminate(this.Display) == false)
                    {
                        //ALOGE("        eglTerminate() failed: %s", EglErrorString(eglGetError()));
                    }
                    this.Display = egl.EGL_NO_DISPLAY;
                }
            }
Пример #28
0
        private void CreateRenderSurface()
        {
            if (mOpenGLES != null && mRenderSurface == EGL.NO_SURFACE)
            {
                // The app can configure the the SwapChainPanel which may boost performance.
                // By default, this template uses the default configuration.
                mRenderSurface = mOpenGLES.CreateSurface(swapChainPanel, null, null);

                // You can configure the SwapChainPanel to render at a lower resolution and be scaled up to
                // the swapchain panel size. This scaling is often free on mobile hardware.
                //
                // One way to configure the SwapChainPanel is to specify precisely which resolution it should render at.
                // Size customRenderSurfaceSize = Size(800, 600);
                // mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, &customRenderSurfaceSize, nullptr);
                //
                // Another way is to tell the SwapChainPanel to render at a certain scale factor compared to its size.
                // e.g. if the SwapChainPanel is 1920x1280 then setting a factor of 0.5f will make the app render at 960x640
                // float customResolutionScale = 0.5f;
                // mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, nullptr, &customResolutionScale);
                //
            }
        }
Пример #29
0
            /**
             * Discard all resources held by this class, notably the EGL context.
             */
            public void release()
            {
                if (mEGLDisplay != EGL14.EglNoDisplay)
                {
                    EGL14.EglDestroySurface(mEGLDisplay, mEGLSurface);
                    EGL14.EglDestroyContext(mEGLDisplay, mEGLContext);
                    EGL14.EglReleaseThread();
                    EGL14.EglTerminate(mEGLDisplay);
                }
                mEGLDisplay = EGL14.EglNoDisplay;
                mEGLContext = EGL14.EglNoContext;
                mEGLSurface = EGL14.EglNoSurface;

                mSurface.Release();

                // this causes a bunch of warnings that appear harmless but might confuse someone:
                //  W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
                //mSurfaceTexture.release();

                mTextureRender  = null;
                mSurface        = null;
                mSurfaceTexture = null;
            }
Пример #30
0
 public BackgroundContext(AndroidGameView view)
 {
     this.view = view;
     foreach (var v in EW.Framework.GLESVersion.GetSupportedGLESVersions())
     {
         eglContext = view.egl.EglCreateContext(view.eglDisplay, view.eglConfig, EGL10.EglNoContext, v.GetAttributes());
         if (eglContext == null || eglContext == EGL10.EglNoContext)
         {
             continue;
         }
         break;
     }
     if (eglContext == null || eglContext == EGL10.EglNoContext)
     {
         eglContext = null;
         throw new Exception("Could not create EGL context" + view.GetErrorAsString());
     }
     int[] pbufferAttribList = new int[] { EGL10.EglWidth, 64, EGL10.EglHeight, 64, EGL10.EglNone };
     surface = view.CreatePBufferSurface(view.eglConfig, pbufferAttribList);
     if (surface == EGL10.EglNoSurface)
     {
         throw new Exception("Could not create Pbuffer Surface" + view.GetErrorAsString());
     }
 }
Пример #31
0
 public static extern bool SwapBuffers(EGLDisplay dpy, EGLSurface surface);
Пример #32
0
 public static extern bool CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
            // called by AppThreadFunction
            public void ovrEgl_CreateContext(EGLContext shareEgl_Context)
            {
                // 152
                ConsoleExtensions.trace("enter ovrEgl_CreateContext, eglGetDisplay");

                if (this.Display != egl.EGL_NO_DISPLAY)
                {
                    return;
                }

                this.Display = egl.eglGetDisplay(default(native_window.ANativeWindow));

                egl.eglInitialize(this.Display, out this.MajorVersion, out this.MinorVersion);

                // Do NOT use eglChooseConfig, because the Android EGL code pushes in multisample
                // flags in eglChooseConfig if the user has selected the "force 4x MSAA" option in
                // settings, and that is completely wasted for our warp target.

                int numConfigs = 0;
                if (egl.eglGetConfigs(this.Display, configs, MAX_CONFIGS, out numConfigs) == false)
                {
                    //ALOGE( "        eglGetConfigs() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }

                ConsoleExtensions.tracei("ovrEgl_CreateContext numConfigs: ", numConfigs);
                //  \VrCubeWorld.Egl.cs:95 ovrEgl_CreateContext numConfigs:  22 


                const int egl_EGL_OPENGL_ES3_BIT_KHR = 0x0040;


                this.Config = default(EGLConfig);

                #region numConfigs
                for (int i = 0; i < numConfigs; i++)
                {
                    int value = 0;

                    egl.eglGetConfigAttrib(this.Display, configs[i], egl.EGL_RENDERABLE_TYPE, out value);
                    if ((value & egl_EGL_OPENGL_ES3_BIT_KHR) != egl_EGL_OPENGL_ES3_BIT_KHR)
                    {
                        continue;
                    }

                    // The pbuffer config also needs to be compatible with normal window rendering
                    // so it can share textures with the window context.
                    egl.eglGetConfigAttrib(this.Display, configs[i], egl.EGL_SURFACE_TYPE, out value);
                    if ((value & (egl.EGL_WINDOW_BIT | egl.EGL_PBUFFER_BIT)) != (egl.EGL_WINDOW_BIT | egl.EGL_PBUFFER_BIT))
                    {
                        continue;
                    }

                    int j = 0;
                    for (; configAttribs[j] != egl.EGL_NONE; j += 2)
                    {
                        egl.eglGetConfigAttrib(this.Display, configs[i], configAttribs[j], out value);
                        if (value != configAttribs[j + 1])
                        {
                            break;
                        }
                    }
                    if (configAttribs[j] == egl.EGL_NONE)
                    {
                        ConsoleExtensions.tracei("ovrEgl_CreateContext config found i: ", i);
                        this.Config = configs[i];
                        break;
                    }
                }
                #endregion

                if (this.Config == default(EGLConfig))
                {
                    ConsoleExtensions.tracei("ovrEgl_CreateContext eglChooseConfig failed");
                    //ALOGE( "        eglChooseConfig() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }


                //ALOGV( "        Context = eglCreateContext( Display, Config, EGL_NO_CONTEXT, contextAttribs )" );
                //this.Context = egl.eglCreateContext(this.Display, this.Config, (shareEgl != NULL) ? shareEgl->Context : egl.EGL_NO_CONTEXT, contextAttribs);
                this.Context = egl.eglCreateContext(this.Display, this.Config, shareEgl_Context, contextAttribs);
                if (this.Context == egl.EGL_NO_CONTEXT)
                {
                    //ALOGE( "        eglCreateContext() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }



                //ALOGV( "        TinySurface = eglCreatePbufferSurface( Display, Config, surfaceAttribs )" );
                this.TinySurface = egl.eglCreatePbufferSurface(this.Display, this.Config, surfaceAttribs);
                if (this.TinySurface == egl.EGL_NO_SURFACE)
                {
                    //ALOGE( "        eglCreatePbufferSurface() failed: %s", EglErrorString( eglGetError() ) );
                    egl.eglDestroyContext(this.Display, this.Context);
                    this.Context = egl.EGL_NO_CONTEXT;
                    return;
                }
                //ALOGV( "        eglMakeCurrent( Display, TinySurface, TinySurface, Context )" );
                if (egl.eglMakeCurrent(this.Display, this.TinySurface, this.TinySurface, this.Context) == false)
                {
                    //ALOGE( "        eglMakeCurrent() failed: %s", EglErrorString( eglGetError() ) );
                    egl.eglDestroySurface(this.Display, this.TinySurface);
                    egl.eglDestroyContext(this.Display, this.Context);
                    this.Context = egl.EGL_NO_CONTEXT;
                    return;
                }

                ConsoleExtensions.trace("exit ovrEgl_CreateContext");

            }
 // called by ovrApp_Clear
 public void ovrEgl_DestroySurface()
 {
     // 320
     if (this.Context != egl.EGL_NO_CONTEXT)
     {
         //ALOGV("        eglMakeCurrent( display, TinySurface, TinySurface, Context )");
         if (egl.eglMakeCurrent(this.Display, this.TinySurface, this.TinySurface, this.Context) == false)
         {
             //ALOGE("        eglMakeCurrent() failed: %s", EglErrorString(eglGetError()));
         }
     }
     if (this.MainSurface != egl.EGL_NO_SURFACE)
     {
         //ALOGV("        eglDestroySurface( Display, MainSurface )");
         if (egl.eglDestroySurface(this.Display, this.MainSurface) == false)
         {
             //ALOGE("        eglDestroySurface() failed: %s", EglErrorString(eglGetError()));
         }
         this.MainSurface = egl.EGL_NO_SURFACE;
     }
 }
Пример #35
0
 public static extern bool SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, int attribute, int value);
Пример #36
0
 public static bool eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { throw null; }
Пример #37
0
 public static bool eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { throw null; }
Пример #38
0
 public static extern bool QuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, out int value);
Пример #39
0
 public static extern bool MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
Пример #40
0
 public static extern bool ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, int buffer);
            // called by AppThreadFunction
            public void ovrEgl_DestroyContext()
            {
                // 259

                if (this.Display != egl.EGL_NO_DISPLAY)
                {
                    //ALOGE("        eglMakeCurrent( Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )");
                    if (egl.eglMakeCurrent(this.Display, egl.EGL_NO_SURFACE, egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT) == false)
                    {
                        //ALOGE("        eglMakeCurrent() failed: %s", EglErrorString(eglGetError()));
                    }
                }
                if (this.Context != egl.EGL_NO_CONTEXT)
                {
                    //ALOGE("        eglDestroyContext( Display, Context )");
                    if (egl.eglDestroyContext(this.Display, this.Context) == false)
                    {
                        //ALOGE("        eglDestroyContext() failed: %s", EglErrorString(eglGetError()));
                    }
                    this.Context = egl.EGL_NO_CONTEXT;
                }
                if (this.TinySurface != egl.EGL_NO_SURFACE)
                {
                    //ALOGE("        eglDestroySurface( Display, TinySurface )");
                    if (egl.eglDestroySurface(this.Display, this.TinySurface) == false)
                    {
                        //ALOGE("        eglDestroySurface() failed: %s", EglErrorString(eglGetError()));
                    }
                    this.TinySurface = egl.EGL_NO_SURFACE;
                }
                if (this.Display != egl.EGL_NO_DISPLAY)
                {
                    //ALOGE("        eglTerminate( Display )");
                    if (egl.eglTerminate(this.Display) == false)
                    {
                        //ALOGE("        eglTerminate() failed: %s", EglErrorString(eglGetError()));
                    }
                    this.Display = egl.EGL_NO_DISPLAY;
                }
            }
Пример #42
0
 public static extern bool DestroySurface(EGLDisplay dpy, EGLSurface surface);
            // called by ovrApp_HandleVrModeChanges
            public void ovrEgl_CreateSurface(native_window.ANativeWindow nativeWindow)
            {
                ConsoleExtensions.trace("enter ovrEgl_CreateSurface");

                //298
                if (this.MainSurface != egl.EGL_NO_SURFACE)
                {
                    return;
                }
                //ALOGV( "        MainSurface = eglCreateWindowSurface( Display, Config, nativeWindow, attribs )" );

                ConsoleExtensions.trace("ovrEgl_CreateSurface, eglCreateWindowSurface, eglMakeCurrent");

                this.MainSurface = egl.eglCreateWindowSurface(this.Display, this.Config, nativeWindow, eglCreateWindowSurface_surfaceAttribs);
                if (this.MainSurface == egl.EGL_NO_SURFACE)
                {
                    //ALOGE( "        eglCreateWindowSurface() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }
                //ALOGV( "        eglMakeCurrent( display, MainSurface, MainSurface, Context )" );
                if (egl.eglMakeCurrent(this.Display, this.MainSurface, this.MainSurface, this.Context) == false)
                {
                    //ALOGE( "        eglMakeCurrent() failed: %s", EglErrorString( eglGetError() ) );
                    return;
                }

                ConsoleExtensions.trace("exit ovrEgl_CreateSurface, ready for ovrRenderer_Create");
            }