Esempio n. 1
0
        private static void Veldridview_OnRendererSet(object sender, EventArgs e)
        {
            var veldridview = sender as VeldridView;

            ViewData viewData = ViewData.Find(veldridview);

            if (viewData == null)
            {
                return;
            }

            viewData.Enabled = true; // IMPORTANT

            paint(veldridview);
        }
Esempio n. 2
0
        // NB: le traitement des events SizeChanged est inutile: il est fait en interne

        static void OnCommandListFactoryChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var veldridview = bindable as VeldridView;

            if (veldridview == null)
            {
                return;
            }

            if (oldValue != null)
            {
                bool _old = ViewData.Dispose(veldridview);
                if (_old)
                {
                    veldridview.OnRendererSet -= Veldridview_OnRendererSet;
                    veldridview.OnUpdate      -= Veldridview_OnUpdate;
                }
            }

            ICommandListFactory _newValue = newValue as ICommandListFactory;

            if (_newValue == null)
            {
                return;
            }

            ViewData viewData = ViewData.Find(veldridview);

            if (viewData == null)
            {
                return;
            }

            viewData.commandListFactory = _newValue;

            veldridview.OnRendererSet += Veldridview_OnRendererSet;
            veldridview.OnUpdate      += Veldridview_OnUpdate;
        }
Esempio n. 3
0
        static void paint(VeldridView veldridview)
        {
            CommandList _commandList = null;

            try
            {
                Debug.WriteLine($"{nameof(paint)}(-) veldridview.Width={veldridview.Width} .Height={veldridview.Height}");

                ViewData viewData = ViewData.Find(veldridview);
                if (viewData == null)
                {
                    return;
                }

                if (viewData.Enabled == false)
                {
                    return;
                }

                ICommandListFactory commandListFactory = viewData.commandListFactory;
                if (commandListFactory == null)
                {
                    return;
                }

                GraphicsDevice _graphicsDevice = veldridview?.VeldridView0Renderer?.GraphicsDevice;
                if (_graphicsDevice == null)
                {
                    return;
                }

                Swapchain swapchain = veldridview?.VeldridView0Renderer?.Swapchain;
                if (swapchain == null)
                {
                    return;
                }

                Framebuffer _framebuffer = swapchain.Framebuffer;
                if (_framebuffer == null)
                {
                    return;
                }

                Debug.WriteLine($"{nameof(paint)} veldridview.Width={veldridview.Width} .Height={veldridview.Height}");
                Debug.WriteLine($"{nameof(paint)} _framebuffer.Width={_framebuffer.Width} .Height={_framebuffer.Height}");

                _commandList = commandListFactory.BuildCommandList(_graphicsDevice, _framebuffer);
                if (_commandList == null)
                {
                    return;
                }

                _graphicsDevice.SubmitCommands(_commandList);
                _graphicsDevice.SwapBuffers(swapchain);
            }
            catch (Exception E)
            {
            }
            finally
            {
                _commandList?.Dispose();
                Debug.WriteLine($"{nameof(paint)}(+) veldridview.Width={veldridview.Width} .Height={veldridview.Height}");
            }
        }