Exemplo n.º 1
0
        private bool Setup()
        {
            System.Threading.Thread.CurrentThread.Name = "rgatUIMain";

            GraphicsDeviceOptions options = new GraphicsDeviceOptions(
                debug: true,
                swapchainDepthFormat: PixelFormat.R8_UNorm,
                syncToVerticalBlank: true,
                resourceBindingModel: ResourceBindingModel.Improved,
                preferDepthRangeZeroToOne: true,
                preferStandardClipSpaceYDirection: false);
            bool loadSuccess = false;

            try
            {
                string windowTitle = $"rgat {CONSTANTS.PROGRAMVERSION.RGAT_VERSION_LONG}";
                Veldrid.StartupUtilities.VeldridStartup.CreateWindowAndGraphicsDevice(
                    new Veldrid.StartupUtilities.WindowCreateInfo(50, 50, 1800, 900, WindowState.Normal, windowTitle),
                    //new GraphicsDeviceOptions(true, null, true, ResourceBindingModel.Improved, true, true),
                    options,
                    preferredBackend: GraphicsBackend.Vulkan,
                    out _window,
                    out _gd);
                loadSuccess = true;
            }
            catch (System.TypeInitializationException e)
            {
                if (e.InnerException != null)
                {
                    if (e.InnerException.GetType() == typeof(System.InvalidOperationException))
                    {
                        Logging.RecordError($"Error: Unable to initialise the Vulkan graphics driver: {e.InnerException.Message}");
                    }
                    else
                    {
                        Logging.RecordError($"Window Creation Exception: {e.InnerException.Message}");
                    }
                }
                else
                {
                    Logging.RecordError($"Error: Unable to initialise the Vulkan graphics driver. {e.Message}");
                }
            }
            catch (Exception e)
            {
                Logging.RecordException($"Error 2: unable to initialise Vulkan driver. {e.Message}", e);
            }

            if (!loadSuccess || _gd is null || _window is null)
            {
                return(false);
            }

            _cl = _gd.ResourceFactory.CreateCommandList();
            _rgatState.InitVeldrid(_gd);
            _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height);
            MediaDrawing.SetController(_controller);

            _rgatUI = new rgatUI(_rgatState, _controller);

            //load in a thread to keep things interactive
            Task loader = Task.Run(() => LoadingThread());


            ImGui.GetIO().ConfigWindowsMoveFromTitleBarOnly = true;
            return(true);
        }