Example #1
0
        /// <summary>
        /// Loads both vertex and fragment shaders from a single custom file
        /// </summary>
        /// <param name="path">The path to the file in which the shaders are.</param>
        /// <returns>An array containing both the vertex and the fragment shader</returns>
        public static Shader[] LoadShaders(string path)
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(typeof(AssetManager));
#endif
            (string vs, string fs) = ShaderHelper.LoadShaders(path);
            Shader[] shaders = new Shader[2];
            shaders[0]      = gd.ResourceFactory.CreateShader(new ShaderDescription(ShaderStages.Vertex, Encoding.UTF8.GetBytes(vs), "main"));
            shaders[0].Name = ExtractNameFromPath(path) + "-Vertex";
            shaders[1]      = gd.ResourceFactory.CreateShader(new ShaderDescription(ShaderStages.Fragment, Encoding.UTF8.GetBytes(fs), "main"));
            shaders[1].Name = ExtractNameFromPath(path) + "-Fragment";
            ResourceCache.AddShaders(shaders);
            return(shaders);
        }