Beispiel #1
0
        public static VeldridRender InitFromMetal(SwapchainSource scs)
        {
            try
            {
                var gd = GraphicsDevice.CreateMetal(new GraphicsDeviceOptions(), new SwapchainDescription(scs, 20, 20, null, false));

                gd.WaitForIdle();

                gd.ResizeMainWindow(270, 800);

                VeldridRender render = new VeldridRender(gd);

                byte[] data = Helpers.GetAssetByteArray("App.Shaders.Shader.metal");

                render.Shaders = new Shader[]
                {
                    render.graphicsDevice.ResourceFactory.CreateShader(new ShaderDescription(ShaderStages.Vertex, data, "shader_vertex", true)),
                    render.graphicsDevice.ResourceFactory.CreateShader(new ShaderDescription(ShaderStages.Fragment, data, "shader_fragment", true))
                };
                return(render);
            }
            catch (Exception ex)
            {
                Logger.AddLog(ex);
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Initialize using Direct3D 11 drivers
        /// </summary>
        /// <returns>New render</returns>
        public static VeldridRender InitFromD3D11(bool invertBGR = false)
        {
            VeldridRender render = new VeldridRender(GraphicsDevice.CreateD3D11(new GraphicsDeviceOptions()));

            render.MakeSpirvShaders(invertBGR);
            render.FlipVertical = false;
            return(render);
        }