/// <summary>
        /// Check the attachment state of a ShaderObject on this ShaderProgram.
        /// </summary>
        /// <param name="shaderObject"></param>
        /// <returns>
        /// It returns a boolean value indicating the attachment state of <paramref name="shaderObject"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="shaderObject"/> is null.
        /// </exception>
        public bool IsAttachedShader(ShaderObject shaderObject)
        {
            if (shaderObject == null)
            {
                throw new ArgumentNullException("shaderObject");
            }

            return(_ProgramObjects.Contains(shaderObject));
        }
        /// <summary>
        /// Detach an attached ShaderObject from this ShaderProgram.
        /// </summary>
        /// <param name="shaderObject">
        /// A <see cref="ShaderObject"/> to be detached to this ShaderProgram.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="shaderObject"/> is null.
        /// </exception>
        public void DetachShader(ShaderObject shaderObject)
        {
            if (shaderObject == null)
            {
                throw new ArgumentNullException("shaderObject");
            }

            // Remove shader
            _ProgramObjects.Remove(shaderObject);
        }
        /// <summary>
        /// Attach a ShaderObject to this ShaderProgram.
        /// </summary>
        /// <param name="shaderObject">
        /// A <see cref="ShaderObject"/> to be attached to this ShaderProgram.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="shaderObject"/> is null.
        /// </exception>
        public void AttachShader(ShaderObject shaderObject)
        {
            if (shaderObject == null)
            {
                throw new ArgumentNullException("sObject");
            }

            // Link object
            _ProgramObjects.Add(shaderObject);
            // Force relink
            _Linked = false;
        }
Example #4
0
            /// <summary>
            /// Create a program from this Program.
            /// </summary>
            /// <returns></returns>
            public ShaderProgram Create()
            {
                if (String.IsNullOrEmpty(Id))
                {
                    throw new InvalidOperationException("invalid program identifier");
                }

                ShaderProgram         shaderProgram        = new ShaderProgram(Id);
                ShaderCompilerContext shaderCompilerParams = new ShaderCompilerContext();

                // Attach required objects
                foreach (Object shaderProgramObject in Objects)
                {
                    ShaderObject shaderObject = new ShaderObject(shaderProgramObject.Stage);

                    // Load source
                    shaderObject.LoadSource(shaderProgramObject.Path);
                    // Attach object
                    shaderProgram.AttachShader(shaderObject);

                    // Take into account required preprocessor symbols
                    foreach (string preprocessorSymbol in shaderProgramObject.Symbols)
                    {
                        shaderCompilerParams.Defines.Add(preprocessorSymbol);
                    }
                }

                // Set compiler parameters
                shaderProgram.CompilationParams = shaderCompilerParams;

                // Register attributes semantic
                foreach (Attribute attribute in Attributes)
                {
                    shaderProgram.SetAttributeSemantic(attribute.Name, attribute.Semantic);
                }

                return(shaderProgram);
            }
			/// <summary>
			/// Create a program from this Program.
			/// </summary>
			/// <returns></returns>
			public ShaderProgram Create()
			{
				if (String.IsNullOrEmpty(Id))
					throw new InvalidOperationException("invalid program identifier");

				ShaderProgram shaderProgram = new ShaderProgram(Id);
				ShaderCompilerContext shaderCompilerParams = new ShaderCompilerContext();

				// Attach required objects
				foreach (Object shaderProgramObject in Objects) {
					ShaderObject shaderObject = new ShaderObject(shaderProgramObject.Stage);

					// Load source
					shaderObject.LoadSource(shaderProgramObject.Path);
					// Attach object
					shaderProgram.AttachShader(shaderObject);

					// Take into account required preprocessor symbols
					foreach (string preprocessorSymbol in shaderProgramObject.Symbols)
						shaderCompilerParams.Defines.Add(preprocessorSymbol);
				}

				// Set compiler parameters
				shaderProgram.CompilationParams = shaderCompilerParams;

				// Register attributes semantic
				foreach (Attribute attribute in Attributes)
					shaderProgram.SetAttributeSemantic(attribute.Name, attribute.Semantic);

				return (shaderProgram);
			}
Example #6
0
 /// <summary>
 /// Load the shader source from an embedded resource
 /// </summary>
 /// <param name="resourcePath">
 /// A <see cref="String"/> that specify the embedded resource path.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown if <paramref name="resourcePath"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if no embedded resource can be found.
 /// </exception>
 public void LoadSource(string resourcePath)
 {
     _SourceStrings = ShaderObject.LoadSourceLines(resourcePath);
 }
Example #7
0
 /// <summary>
 /// Load the shader source from a stream.
 /// </summary>
 /// <param name="sourceStream">
 /// A <see cref="Stream"/>that holds the source lines.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown in the case <paramref name="sourceStream"/> is null.
 /// </exception>
 public void LoadSource(Stream sourceStream)
 {
     _SourceStrings = ShaderObject.LoadSourceLines(sourceStream);
 }
Example #8
0
		/// <summary>
		/// Check the attachment state of a ShaderObject on this ShaderProgram.
		/// </summary>
		/// <param name="shaderObject"></param>
		/// <returns>
		/// It returns a boolean value indicating the attachment state of <paramref name="shaderObject"/>.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// Exception thrown if <paramref name="shaderObject"/> is null.
		/// </exception>
		public bool IsAttachedShader(ShaderObject shaderObject)
		{
			if (shaderObject == null)
				throw new ArgumentNullException("shaderObject");

			return (_ProgramObjects.Contains(shaderObject));
		}
Example #9
0
		/// <summary>
		/// Detach an attached ShaderObject from this ShaderProgram.
		/// </summary>
		/// <param name="shaderObject">
		/// A <see cref="ShaderObject"/> to be detached to this ShaderProgram.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Exception thrown if <paramref name="shaderObject"/> is null.
		/// </exception>
		public void DetachShader(ShaderObject shaderObject)
		{
			if (shaderObject == null)
				throw new ArgumentNullException("shaderObject");

			// Remove shader
			_ProgramObjects.Remove(shaderObject);
        }
Example #10
0
		/// <summary>
		/// Attach a ShaderObject to this ShaderProgram.
		/// </summary>
		/// <param name="shaderObject">
		/// A <see cref="ShaderObject"/> to be attached to this ShaderProgram.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Exception thrown if <paramref name="shaderObject"/> is null.
		/// </exception>
		public void AttachShader(ShaderObject shaderObject)
		{
			if (shaderObject == null)
				throw new ArgumentNullException("sObject");

			// Link object
			_ProgramObjects.Add(shaderObject);
			// Force relink
			_Linked = false;
		}