public void Bind(ProgramAttribute attribute, GraphicsBuffer buffer, int offsetInBytes, Format format, int stride) { if (attribute == null) throw new ArgumentNullException("attribute"); throw new NotImplementedException(); //GLExt.VertexAttribFormat(attribute.Index, format.ComponentCount, format.VertexAttribPonterType, format.IsNormalized, offsetInBytes); }
public override bool Link() { bool result = base.Link(); Unlink(); if (result) { boneIndices = Attributes["BoneIndices"]; boneWeights = Attributes["BoneWeights"]; normal = Attributes["Normal"]; position = Attributes["Position"]; texel = Attributes["Texel"]; (ambientLight = Uniforms["AmbientLight"]).Set(ref ambientLightValue); (diffuseColor = Uniforms["DiffuseColor"]).Set(ref diffuseColorValue); (diffuseMap = Uniforms["DiffuseMap"]).Set(diffuseMapValue ?? Device.WhiteTexture); (displayMode = Uniforms["DisplayMode"]).Set((int)displayModeValue); (projection = Uniforms["Projection"]).Set(ref projectionValue); (view = Uniforms["View"]).Set(ref viewValue); (world = Uniforms["World"]).Set(ref worldValue); } return(result); }
public void BindAttributes(IChannelAttributeSource channelAttributes) { foreach (ModelAttribute modelAttribute in attributes) { ProgramAttribute attribute = channelAttributes.TryGetChannelAttribute(modelAttribute); if (attribute != null) { attribute.Bind(modelAttribute.Buffer, modelAttribute.OffsetInBytes, modelAttribute.Format, modelAttribute.Stride); } } }
/// <summary> /// Bind the vertex declaration to the program. /// </summary> /// <param name="program"></param> /// <param name="mesh"></param> /// <param name="stride"></param> public void Bind(ModelProgram program, ModelMesh mesh, int stride) { GraphicsBuffer buffer = Model.Buffer; foreach (ModelVertexAttribute attribute in Attributes) { int offset = attribute.Offset + mesh.BufferDataOffset; ProgramAttribute programAttribute = attribute.MatchAttribute(program); if (programAttribute != null) { programAttribute.Bind(buffer, offset, attribute.GraphicsFormat, stride); } } }
private QuadProgram() : base( vertex: new VertexShader(typeof(QuadProgram).GetAssociatedResource("Vertex.glsl")), fragment: new FragmentShader(typeof(QuadProgram).GetAssociatedResource("Fragment.glsl")) ) { Textures = new ProgramUniform <Texture2D>[] { GetUniform <Texture2D>("texture0", GL.TEXTURE0), GetUniform <Texture2D>("texture1", GL.TEXTURE1), GetUniform <Texture2D>("texture2", GL.TEXTURE2), GetUniform <Texture2D>("texture3", GL.TEXTURE3), GetUniform <Texture2D>("texture4", GL.TEXTURE4), GetUniform <Texture2D>("texture5", GL.TEXTURE5), GetUniform <Texture2D>("texture6", GL.TEXTURE6), GetUniform <Texture2D>("texture7", GL.TEXTURE7) }; Vertex = GetAttribute <Vector2>("vertex"); Transform = GetAttribute <Matrix3x2>("transform"); Color = GetAttribute <Color4ub>("color", normalized: true); Texture = GetAttribute <int>("texture"); TextureCoordinates0 = GetAttribute <Vector2>("texture_coordinates0"); TextureCoordinates1 = GetAttribute <Vector2>("texture_coordinates1"); }
void Unlink() { ambientLight = diffuseColor = diffuseMap = projection = view = world = null; boneIndices = boneWeights = normal = position = texel = null; }
/// <summary>Link the program, returning the result.</summary> /// <returns></returns> public override bool Link() { bool result = base.Link(); Unlink(); if (result) { boneIndices = Attributes["BoneIndices"]; boneWeights = Attributes["BoneWeights"]; normal = Attributes["Normal"]; position = Attributes["Position"]; texel = Attributes["Texel"]; (ambientLight = Uniforms["AmbientLight"]).Set(ref ambientLightValue); (diffuseColor = Uniforms["DiffuseColor"]).Set(ref diffuseColorValue); (diffuseMap = Uniforms["DiffuseMap"]).Set(diffuseMapValue ?? Device.WhiteTexture); (displayMode = Uniforms["DisplayMode"]).Set((int)displayModeValue); (projection = Uniforms["Projection"]).Set(ref projectionValue); (view = Uniforms["View"]).Set(ref viewValue); (world = Uniforms["World"]).Set(ref worldValue); } return result; }