Exemple #1
0
        public RenderView()
        {
            WindowCreateInfo windowCI = new WindowCreateInfo()
            {
                X            = 100,
                Y            = 100,
                WindowWidth  = 960,
                WindowHeight = 540,
                WindowTitle  = "Veldrid Tutorial"
            };

            Window = VeldridStartup.CreateWindow(ref windowCI);

            GraphicsDeviceOptions options = new GraphicsDeviceOptions
            {
                PreferStandardClipSpaceYDirection = true,
                PreferDepthRangeZeroToOne         = true
            };

            void CreateAndAddCursor(SDL_SystemCursor type)
            {
                var cursor = Sdl2Native.SDL_CreateSystemCursor(type);

                cursorMap.Add(type, cursor);
            }

            CreateAndAddCursor(SDL_SystemCursor.Arrow);
            CreateAndAddCursor(SDL_SystemCursor.Crosshair);
            CreateAndAddCursor(SDL_SystemCursor.Hand);
            CreateAndAddCursor(SDL_SystemCursor.IBeam);
            CreateAndAddCursor(SDL_SystemCursor.No);
            CreateAndAddCursor(SDL_SystemCursor.SizeAll);
            CreateAndAddCursor(SDL_SystemCursor.SizeNESW);
            CreateAndAddCursor(SDL_SystemCursor.SizeNS);
            CreateAndAddCursor(SDL_SystemCursor.SizeNWSE);
            CreateAndAddCursor(SDL_SystemCursor.SizeWE);
            CreateAndAddCursor(SDL_SystemCursor.Wait);
            CreateAndAddCursor(SDL_SystemCursor.WaitArrow);

            GraphicsDevice = dispose.Add(VeldridStartup.CreateGraphicsDevice(Window, options, GraphicsBackend.Direct3D11));

            Window.Resized += () =>
            {
                GraphicsDevice.MainSwapchain.Resize((uint)Window.Width, (uint)Window.Height);
            };
        }
Exemple #2
0
        public DesktopWindow(string title, uint width, uint height)
        {
            const int centered = Sdl2Native.SDL_WINDOWPOS_CENTERED;

            Sdl2Native.SDL_Init(SDLInitFlags.Video | SDLInitFlags.GameController);
            _window = new Sdl2Window(title,
                                     centered, centered,
                                     (int)width, (int)height,
                                     SDL_WindowFlags.OpenGL,
                                     threadedProcessing: false
                                     );
            SwapchainSource = VeldridStartup.GetSwapchainSource(_window);

            _arrow  = Sdl2Native.SDL_CreateSystemCursor(SDL_SystemCursor.Arrow);
            _hand   = Sdl2Native.SDL_CreateSystemCursor(SDL_SystemCursor.Hand);
            _wait   = Sdl2Native.SDL_CreateSystemCursor(SDL_SystemCursor.Wait);
            _cursor = SystemCursor.Arrow;
        }