Beispiel #1
0
        public EGLSurface CreateSurface(SwapChainPanel panel)
        {
            if (panel == null)
            {
                throw new ArgumentNullException("SwapChainPanel parameter is invalid");
            }

            EGLSurface surface = Egl.EGL_NO_SURFACE;

            EGLint[] 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
            {
                { Egl.EGLNativeWindowTypeProperty, panel }
            };

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

            return(surface);
        }
Beispiel #2
0
        public EGLSurface CreateSurface(SwapChainPanel panel, Size?renderSurfaceSize, float?resolutionScale)
        {
            if (panel == null)
            {
                throw new ArgumentNullException("SwapChainPanel parameter is invalid");
            }

            EGLSurface surface = Egl.EGL_NO_SURFACE;

            EGLint[] 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(mEglDisplay, mEglConfig, surfaceCreationProperties, surfaceAttributes);
            if (surface == Egl.EGL_NO_SURFACE)
            {
                throw new Exception("Failed to create EGL surface");
            }

            return(surface);
        }