Exemplo n.º 1
0
        private static void ConfigureGraphicsContext(Application application, Surface surface)
        {
            GraphicsContext graphicsContext = new GLGraphicsContext(GraphicsBackend.WebGL2);

            graphicsContext.CreateDevice();
            SwapChainDescription swapChainDescription = new SwapChainDescription()
            {
                SurfaceInfo              = surface.SurfaceInfo,
                Width                    = surface.Width,
                Height                   = surface.Height,
                ColorTargetFormat        = PixelFormat.R8G8B8A8_UNorm,
                ColorTargetFlags         = TextureFlags.RenderTarget | TextureFlags.ShaderResource,
                DepthStencilTargetFormat = PixelFormat.D24_UNorm_S8_UInt,
                DepthStencilTargetFlags  = TextureFlags.DepthStencil,
                SampleCount              = TextureSampleCount.None,
                IsWindowed               = true,
                RefreshRate              = 60
            };
            var swapChain = graphicsContext.CreateSwapChain(swapChainDescription);

            swapChain.VerticalSync = true;

            var graphicsPresenter = application.Container.Resolve <GraphicsPresenter>();
            var firstDisplay      = new Display(surface, swapChain);

            graphicsPresenter.AddDisplay("DefaultDisplay", firstDisplay);

            application.Container.RegisterInstance(graphicsContext);
        }