Exemple #1
0
 public GLView()
 {
     mOpenGLES      = new OpenGLES();
     mRenderSurface = EGL.NO_SURFACE;
     Window.Current.VisibilityChanged += (win, args) => OnVisibilityChanged(win, args);
     Loaded += (sender, args) => OnLoaded(sender, args);
 }
Exemple #2
0
 public void MakeCurrent(EGLSurface surface)
 {
     if (EGL.MakeCurrent(mEglDisplay, surface, surface, mEglContext) == EGL.FALSE)
     {
         throw new ApplicationException("Failed to make EGLSurface current");
     }
 }
Exemple #3
0
 public void DestroySurface(EGLSurface surface)
 {
     if (mEglDisplay != EGL.NO_DISPLAY && surface != EGL.NO_SURFACE)
     {
         EGL.DestroySurface(mEglDisplay, surface);
     }
 }
Exemple #4
0
        private void DestroyRenderSurface()
        {
            if (mOpenGLES != null)
            {
                mOpenGLES.DestroySurface(mRenderSurface);
            }

            mRenderSurface = EGL.NO_SURFACE;
        }
Exemple #5
0
        public EGLSurface CreateSurface(SwapChainPanel panel, Size?renderSurfaceSize, float?resolutionScale)
        {
            if (panel == null)
            {
                throw new ArgumentException("SwapChainPanel parameter is invalid");
            }

            if (renderSurfaceSize != null && resolutionScale != null)
            {
                throw new ArgumentException("A size and a scale can't both be specified");
            }

            EGLSurface surface = EGL.NO_SURFACE;

            int[] surfaceAttributes =
            {
                // EGL.ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL.ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above).
                // If you have compilation issues with it then please update your Visual Studio templates.
                EGL.ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL.TRUE,
                EGL.NONE
            };

            // Create a PropertySet and initialize with the EGLNativeWindowType.
            PropertySet surfaceCreationProperties = new PropertySet();

            surfaceCreationProperties.Add(ANGLEWindowsStore.EGLNativeWindowTypeProperty, panel);

            // If a render surface size is specified, add it to the surface creation properties
            if (renderSurfaceSize != null)
            {
                surfaceCreationProperties.Add(ANGLEWindowsStore.EGLRenderSurfaceSizeProperty,
                                              PropertyValue.CreateSize((Size)renderSurfaceSize));
            }

#if TODO
            // If a resolution scale is specified, add it to the surface creation properties
            if (resolutionScale != null)
            {
                surfaceCreationProperties.Add(ANGLEWindowsStore.EGLRenderResolutionScaleProperty,
                                              PropertyValue.CreateSingle(resolutionScale));
            }
#endif

            surface = EGL.CreateWindowSurface(mEglDisplay, mEglConfig, surfaceCreationProperties, surfaceAttributes);
            if (surface == EGL.NO_SURFACE)
            {
                throw new ApplicationException("Failed to create EGL surface");
            }

            return(surface);
        }
Exemple #6
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(this, 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 = new Size(800, 600);
                // mRenderSurface = mOpenGLES.CreateSurface(this, customRenderSurfaceSize, null);
                //
                // 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);
                //
            }
        }
Exemple #7
0
 public static int DestroySurface(EGLDisplay dpy, EGLSurface surface)
 {
     return(eglDestroySurface(dpy.Ptr, surface.Ptr));
 }
Exemple #8
0
 public static int QuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, ref int value)
 {
     return(eglQuerySurface(dpy.Ptr, surface.Ptr, attribute, ref value));
 }
Exemple #9
0
 public static int MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
 {
     return(eglMakeCurrent(dpy.Ptr, draw.Ptr, read.Ptr, ctx.Ptr));
 }
Exemple #10
0
 public static int SwapBuffers(EGLDisplay dpy, EGLSurface surface)
 {
     return(eglSwapBuffers(dpy.Ptr, surface.Ptr));
 }
Exemple #11
0
 public int SwapBuffers(EGLSurface surface)
 {
     return(EGL.SwapBuffers(mEglDisplay, surface));
 }
Exemple #12
0
 public void GetSurfaceDimensions(EGLSurface surface, ref int width, ref int height)
 {
     EGL.QuerySurface(mEglDisplay, surface, EGL.WIDTH, ref width);
     EGL.QuerySurface(mEglDisplay, surface, EGL.HEIGHT, ref height);
 }