/// <summary> /// Initializes a new <see cref="ProgramAttribute"/>. /// </summary> /// <param name="program">The <see cref="ShaderProgram"/> the <see cref="ProgramAttribute"/> belongs to.</param> /// <param name="index">The uniform index as per GL.GetProgramInterface.</param> public ProgramAttribute(ShaderProgram program, int index) { Contract.Requires<ArgumentNullException>(program != null); Contract.Requires<ArgumentOutOfRangeException>(index >= 0); this.Program = program; ActiveAttribType aat; int size; base.Name = GL.GetActiveAttrib(program, index, out size, out aat); this.Location = GL.GetAttribLocation(program, this.Name); this.Type = aat; }
/// <summary> /// Initializes a new <see cref="ProgramUniform"/>. /// </summary> /// <param name="program">The <see cref="ShaderProgram"/> the <see cref="ProgramUniform"/> belongs to.</param> /// <param name="index">The uniform index as per GL.GetProgramInterface.</param> public ProgramUniform(ShaderProgram program, int index) { Contract.Requires<ArgumentNullException>(program != null); Contract.Requires<ArgumentOutOfRangeException>(index >= 0); this.Program = program; int size; ActiveUniformType uniformType; base.Name = GL.GetActiveUniform(this.Program, index, out size, out uniformType); this.Location = GL.GetUniformLocation(program, this.Name); this.Type = uniformType; // Set indirectly to fire event }
public EffectPass(ShaderProgram program, bool ownsProgram) { Contract.Requires<ArgumentNullException>(program != null); this.ownsProgram = ownsProgram; this.ShaderProgram = program; this.Uniforms = this.ShaderProgram.Uniforms.Select((Func<KeyValuePair<string, ProgramUniform>, EffectUniform>)(kvp => { if (kvp.Value.Type.IsSampler()) { return new SamplerEffectUniform(this, kvp.Value, 0); } else if (kvp.Value.Type.IsPrimitiveValue() || kvp.Value.Type.IsVector() || kvp.Value.Type.IsMatrix()) { return new DataEffectUniform(this, kvp.Value); } else { throw new NotSupportedException("Unknown uniform type {0}!".FormatWith(kvp.Value.Type)); } })).ToImmutableDictionary(eu => eu.Name); }
public EffectPass(ShaderProgram program) : this(program, false) { Contract.Requires<ArgumentNullException>(program != null); }
/// <summary> /// Detaches the <see cref="Shader"/> from the specified <see cref="ShaderProgram"/>. /// </summary> /// <remarks>Triggers initialization.</remarks> /// <param name="program">The <see cref="ShaderProgram"/> to detach from.</param> public void DetachFrom(ShaderProgram program) { Contract.Requires<ArgumentNullException>(program != null); this.VerifyAccess(); GL.DetachShader(program, this); }