private static void ConfigureGraphicsContext(Application application, Window window) { GraphicsContext graphicsContext = new Evergine.DirectX11.DX11GraphicsContext(); 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); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Create app WaveApplication = new MyApplication(); // Create Window System var windowsSystem = new Evergine.WPF.WPFWindowsSystem(this); WaveApplication.Container.RegisterInstance(windowsSystem); // Create Graphic context var graphicsContext = new Evergine.DirectX11.DX11GraphicsContext(); graphicsContext.CreateDevice(); WaveApplication.Container.RegisterInstance(graphicsContext); // Creates XAudio device var xaudio = new Evergine.XAudio2.XAudioDevice(); WaveApplication.Container.RegisterInstance(xaudio); Stopwatch clockTimer = Stopwatch.StartNew(); windowsSystem.Run( () => { WaveApplication.Initialize(); }, () => { var gameTime = clockTimer.Elapsed; clockTimer.Restart(); WaveApplication.UpdateFrame(gameTime); WaveApplication.DrawFrame(gameTime); graphicsContext.DXDeviceContext.Flush(); }); }
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); }