Exemplo n.º 1
0
        public void CreateSurface(SwapChainPanel panel, Size?renderSurfaceSize, float?resolutionScale)
        {
            if (panel == null)
            {
                throw new ArgumentNullException("SwapChainPanel parameter is invalid");
            }

            EGLSurface surface = Egl.EGL_NO_SURFACE;

            int[] surfaceAttributes = new[]
            {
                // 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.EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, Egl.EGL_TRUE,
                Egl.EGL_NONE
            };

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

            surfaceCreationProperties.Add(Egl.EGLNativeWindowTypeProperty, panel);

            // If a render surface size is specified, add it to the surface creation properties
            if (renderSurfaceSize.HasValue)
            {
                PropertySetExtensions.AddSize(surfaceCreationProperties, Egl.EGLRenderSurfaceSizeProperty, renderSurfaceSize.Value);
            }

            // If a resolution scale is specified, add it to the surface creation properties
            if (resolutionScale.HasValue)
            {
                PropertySetExtensions.AddSingle(surfaceCreationProperties, Egl.EGLRenderResolutionScaleProperty, resolutionScale.Value);
            }

            surface = Egl.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceCreationProperties, surfaceAttributes);
            if (surface == Egl.EGL_NO_SURFACE)
            {
                throw new Exception("Failed to create EGL surface");
            }

            eglSurface = surface;
        }
Exemplo n.º 2
0
        public void CreateSurface(SwapChainPanel panel, Size?renderSurfaceSize, float?resolutionScale)
        {
            if (panel == null)
            {
                throw new ArgumentNullException("SwapChainPanel parameter is invalid");
            }

            EGLSurface surface = Egl.EGL_NO_SURFACE;

            int[] surfaceAttributes = new[]
            {
                Egl.EGL_NONE
            };

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

            surfaceCreationProperties.Add(Egl.EGLNativeWindowTypeProperty, panel);

            // If a render surface size is specified, add it to the surface creation properties
            if (renderSurfaceSize.HasValue)
            {
                PropertySetExtensions.AddSize(surfaceCreationProperties, Egl.EGLRenderSurfaceSizeProperty, renderSurfaceSize.Value);
            }

            // If a resolution scale is specified, add it to the surface creation properties
            if (resolutionScale.HasValue)
            {
                PropertySetExtensions.AddSingle(surfaceCreationProperties, Egl.EGLRenderResolutionScaleProperty, resolutionScale.Value);
            }

            surface = Egl.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceCreationProperties, surfaceAttributes);
            if (surface == Egl.EGL_NO_SURFACE)
            {
                throw new Exception("Failed to create EGL surface");
            }

            eglSurface = surface;
        }