예제 #1
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);
        }