Exemple #1
0
        private static void ConfigureGraphicsContext(Application application, Window window)
        {
            GraphicsContext graphicsContext = new Evergine.Vulkan.VKGraphicsContext();

            graphicsContext.DefaultBufferUploaderSize  = 128 * 1024 * 1024;
            graphicsContext.DefaultTextureUploaderSize = 512 * 1024 * 1024;

            graphicsContext.CreateDevice();
            SwapChainDescription swapChainDescription = new SwapChainDescription()
            {
                SurfaceInfo              = window.SurfaceInfo,
                Width                    = window.Width,
                Height                   = window.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(window, swapChain);

            graphicsPresenter.AddDisplay("DefaultDisplay", firstDisplay);

            application.Container.RegisterInstance(graphicsContext);
        }
Exemple #2
0
        private static GraphicsContext CreateGraphicsContext()
        {
            GraphicsContext graphicsContext;

            if (DeviceInfo.PlatformType == PlatformType.Windows)
            {
                graphicsContext = new Evergine.DirectX11.DX11GraphicsContext();
            }
            else if (DeviceInfo.PlatformType == PlatformType.Linux)
            {
                graphicsContext = new Evergine.Vulkan.VKGraphicsContext();
            }
            else if (DeviceInfo.PlatformType == PlatformType.MacOS)
            {
                graphicsContext = new Evergine.Metal.MTLGraphicsContext();
            }
            else
            {
                throw new Exception("Graphics context can not be created.");
            }

            return(graphicsContext);
        }