public GetAttributeLocation ( string attributeName ) : int | ||
attributeName | string | |
리턴 | int |
public int GetAttributeLocation(string attributeName)
{
// If we don't have the attribute name in the dictionary, get it's
// location and add it.
int location;
if (!attributeNamesToLocations.TryGetValue(attributeName, out location))
{
location = glGetAttribLocation(this.ProgramId, attributeName);
if (location < 0)
{
Debug.WriteLine(string.Format("Failed to getAttribLocation for [{0}]", attributeName));
}
attributeNamesToLocations[attributeName] = location;
}
// Return the attribute location.
return location;
}
/// <summary> /// 在使用<see cref="VertexArrayObject"/>后,此方法只会执行一次。 /// </summary> /// <param name="e"></param> /// <param name="shaderProgram"></param> public override void Render(RenderEventArgs e, ShaderProgram shaderProgram) { uint location = shaderProgram.GetAttributeLocation(this.VarNameInVertexShader); GL.BindBuffer(BufferTarget.ArrayBuffer, this.BufferID); GL.GetDelegateFor <GL.glVertexAttribPointer>()(location, this.DataSize, this.DataType, false, 0, IntPtr.Zero); GL.GetDelegateFor <GL.glEnableVertexAttribArray>()(location); }