Beispiel #1
0
 private static void Panel_Ready(object sender, EventArgs e)
 {
     demo = new VeldridDemoProgram(
         new GraphicsDeviceOptions
     {
         PreferDepthRangeZeroToOne         = true,
         PreferStandardClipSpaceYDirection = true,
         ResourceBindingModel = ResourceBindingModel.Improved,
         SwapchainDepthFormat = (PixelFormat)SwapchainDepthFormat.R16_UNorm,
         SwapchainSrgbFormat  = false,
         SyncToVerticalBlank  = true,
         HasMainSwapchain     = false
     },
         panel,
         canceller.Token);
     //demo.Error += form.SetError;
     demo.Update += Demo_Update;
     demo.Start();
 }
Beispiel #2
0
        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());
            }
        }