protected override void OnActivated(EventArgs e) { base.OnActivated(e); if (MainWindow is MainWindow wind) { window = wind; window.RequestStats += MainForm_RequestStats; panel = window.Panel; panel.Ready += Panel_Ready; panel.Destroying += Panel_Destroying; canceller = new CancellationTokenSource(); keys = new Win32KeyEventSource(canceller.Token); keys.AddKeyAlias("up", Keys.Up); keys.AddKeyAlias("down", Keys.Down); keys.AddKeyAlias("left", Keys.Left); keys.AddKeyAlias("right", Keys.Right); keys.DefineAxis("horizontal", "left", "right"); keys.DefineAxis("forward", "up", "down"); mouse = new Win32MouseMoveEventSource(canceller.Token); mouse.Moved += Mouse_Moved; } }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; using var form = window = new MainWindow(); panel = form.Panel; panel.Ready += Panel_Ready; panel.Destroying += Panel_Destroying; window.RequestStats += MainForm_RequestStats; canceller = new CancellationTokenSource(); keys = new Win32KeyEventSource(canceller.Token); keys.AddKeyAlias("up", Keys.Up); keys.AddKeyAlias("down", Keys.Down); keys.AddKeyAlias("left", Keys.Left); keys.AddKeyAlias("right", Keys.Right); keys.DefineAxis("horizontal", "left", "right"); keys.DefineAxis("forward", "up", "down"); mouse = new Win32MouseMoveEventSource(canceller.Token); mouse.Moved += Mouse_Moved; Application.Run(form); }
private static void Main() { try { canceller = new CancellationTokenSource(); window = new Sdl2Window( "Veldrid - Console", 100, 100, 1280, 720, SDL_WindowFlags.AllowHighDpi | SDL_WindowFlags.OpenGL | SDL_WindowFlags.Shown, true); using var device = VeldridStartup.CreateGraphicsDevice( window, new GraphicsDeviceOptions { SwapchainDepthFormat = PixelFormat.D24_UNorm_S8_UInt, ResourceBindingModel = ResourceBindingModel.Improved, SwapchainSrgbFormat = false, SyncToVerticalBlank = true, PreferDepthRangeZeroToOne = true, PreferStandardClipSpaceYDirection = true, }, GraphicsBackend.Vulkan); keys = new Win32KeyEventSource(canceller.Token); keys.AddKeyAlias("up", Keys.Up); keys.AddKeyAlias("down", Keys.Down); keys.AddKeyAlias("left", Keys.Left); keys.AddKeyAlias("right", Keys.Right); keys.AddKeyAlias("quit", Keys.Escape); keys.DefineAxis("horizontal", "left", "right"); keys.DefineAxis("forward", "up", "down"); mouse = new Win32MouseMoveEventSource(canceller.Token); mouse.Moved += Mouse_Moved; demo = new VeldridDemoProgram( device, canceller.Token); demo.Error += Demo_Error;; demo.Update += Demo_Update; keys.Start(); mouse.Start(); demo.Start(); while (!canceller.IsCancellationRequested) { _ = window.PumpEvents(); } mouse.Quit(); keys.Quit(); demo.Quit(); demo.Dispose(); window.Close(); } catch (Exception exp) { Console.Error.WriteLine(exp.Unroll()); } }