Ejemplo n.º 1
0
        /// <summary>
        /// Merge a ShaderLibrary loaded from an embedded resource with <see cref="Instance"/>.
        /// </summary>
        /// <param name="shadersLibrary">
        /// A <see cref="ShadersLibrary"/> that specify the embedded resources.
        /// </param>
        public void Merge(ShadersLibrary shadersLibrary)
        {
            if (shadersLibrary == null)
            {
                throw new ArgumentNullException(nameof(shadersLibrary));
            }

            if (_ShadersLibrary.Includes == null)
            {
                _ShadersLibrary.Includes = new List <Include>();
            }
            if (shadersLibrary.Includes != null)
            {
                _ShadersLibrary.Includes.AddRange(shadersLibrary.Includes);
            }

            if (_ShadersLibrary.Objects == null)
            {
                _ShadersLibrary.Objects = new List <Object>();
            }
            if (shadersLibrary.Objects != null)
            {
                _ShadersLibrary.Objects.AddRange(shadersLibrary.Objects);
            }

            if (_ShadersLibrary.Programs == null)
            {
                _ShadersLibrary.Programs = new List <Program>();
            }
            if (shadersLibrary.Programs != null)
            {
                _ShadersLibrary.Programs.AddRange(shadersLibrary.Programs);
            }
        }
Ejemplo n.º 2
0
        public void MergeLibrary(ShadersLibrary shadersLibrary)
        {
            if (shadersLibrary == null)
            {
                throw new ArgumentNullException(nameof(shadersLibrary));
            }

            if (shadersLibrary.Includes == null)
            {
                return;
            }

            foreach (ShadersLibrary.Include shaderLibraryInclude in shadersLibrary.Includes)
            {
                if (_IncludeFileSystem.ContainsKey(shaderLibraryInclude.Path))
                {
                    throw new InvalidOperationException(String.Format("include path '{0}' is duplicated", shaderLibraryInclude.Path));
                }

                ShaderInclude shaderInclude;

                LinkResource(shaderInclude = new ShaderInclude(shaderLibraryInclude.Path));

                shaderInclude.LoadSource(shaderLibraryInclude.Resource);

                _IncludeFileSystem.Add(shaderInclude.IncludePath, shaderInclude);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Merge a ShaderLibrary loaded from an embedded resource with <see cref="Instance"/>.
        /// </summary>
        /// <param name="resourcePath">
        /// A <see cref="String"/> that specify the embedded resource path.
        /// </param>
        public static void Merge(string resourcePath)
        {
            ShadersLibrary embeddedShadersLibrary = Load(resourcePath);

            // Merge information
            _ShadersLibrary.Includes.AddRange(embeddedShadersLibrary.Includes);
            _ShadersLibrary.Objects.AddRange(embeddedShadersLibrary.Objects);
            _ShadersLibrary.Programs.AddRange(embeddedShadersLibrary.Programs);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Merge a ShaderLibrary loaded from an embedded resource with <see cref="Instance"/>.
        /// </summary>
        /// <param name="resourcePath">
        /// A <see cref="string"/> that specify the embedded resources.
        /// </param>
        public void Merge(string resourcePath)
        {
            ShadersLibrary embeddedShadersLibrary = ShadersLibrary.Load(resourcePath);

            Merge(embeddedShadersLibrary);
        }