Example #1
0
    public MainForm(GraphicsBackend backend, string exeDir, string shaderSubdir)
    {
        InitializeComponent();

        Shown += (sender, e) => FormReady = true;

        GraphicsDeviceOptions options = new(
            false,
            Veldrid.PixelFormat.R32_Float,
            false,
            ResourceBindingModel.Improved);

        Surface = new VeldridSurface(backend, options);
        Surface.VeldridInitialized += (sender, e) => VeldridReady = true;

        Content = Surface;

        ovpSettings = new OVPSettings();
        ovpSettings.drawFilled(true);
        ovpSettings.drawDrawn(true);
        ovpSettings.drawPoints(true);

        addPolys();

        Driver = new VeldridDriver(ref ovpSettings, ref Surface)
        {
            Surface             = Surface,
            ExecutableDirectory = exeDir,
            ShaderSubdirectory  = shaderSubdir
        };

        // TODO: Make this binding actually work both ways.
        CmdAnimate.Bind <bool>("Checked", Driver, "Animate");
        CmdClockwise.Bind <bool>("Checked", Driver, "Clockwise");
    }
Example #2
0
        public MainForm(GraphicsBackend backend)
        {
            InitializeComponent();

            Shown += (sender, e) => FormReady = true;

            // A depth buffer isn't strictly necessary for this project, which uses
            // only 2D vertex coordinates, but it's helpful to create one for the
            // sake of demonstration.
            //
            // The "improved" resource binding model changes how resource slots are
            // assigned in the Metal backend, allowing it to work like the others,
            // so the numbers used in calls to CommandList.SetGraphicsResourceSet
            // will make more sense to developers used to e.g. OpenGL or Direct3D.
            var options = new GraphicsDeviceOptions(
                false,
                PixelFormat.R32_Float,
                false,
                ResourceBindingModel.Improved);

            Surface      = new VeldridSurface(backend, options);
            Surface.Size = new Eto.Drawing.Size(200, 200);
            Surface.VeldridInitialized += (sender, e) => VeldridReady = true;

            Content = Surface;

            Driver = new VeldridDriver
            {
                Surface = Surface
            };

            // TODO: Make this binding actually work both ways.
            CmdAnimate.Bind <bool>("Checked", Driver, "Animate");
            CmdClockwise.Bind <bool>("Checked", Driver, "Clockwise");
        }