Difference between revisions of "Mesh:attachAttribute"

m
m (Notes)
Line 15: Line 15:
 
If a Mesh wasn't [[love.graphics.newMesh|created]] with a custom vertex format, it will have 3 vertex attributes named <code>VertexPosition</code>, <code>VertexTexCoord</code>, and <code>VertexColor</code>.
 
If a Mesh wasn't [[love.graphics.newMesh|created]] with a custom vertex format, it will have 3 vertex attributes named <code>VertexPosition</code>, <code>VertexTexCoord</code>, and <code>VertexColor</code>.
  
Custom named attributes can be accessed in a [[Shader|vertex shader]] by declaring them as <code>attribute vec4 MyCustomAttribute<code> at the top-level of the vertex shader code. The name must match what was specified in the vertex format and in the <code>name</code> argument to ''Mesh:attachAttribute''.
+
Custom named attributes can be accessed in a [[Shader|vertex shader]] by declaring them as <code>attribute vec4 MyCustomAttribute</code> at the top-level of the vertex shader code. The name must match what was specified in the vertex format and in the <code>name</code> argument to ''Mesh:attachAttribute''.
  
 
== See Also ==
 
== See Also ==

Revision as of 22:56, 13 December 2015

Available since LÖVE 0.10.0
This function is not supported in earlier versions.

Attaches a vertex attribute from a different Mesh onto this Mesh, for use when drawing. This can be used to share vertex attribute data between several different Meshes.

Function

Synopsis

Mesh:attachAttribute( name, mesh )

Arguments

string name
The name of the vertex attribute to attach.
Mesh mesh
The Mesh to get the vertex attribute from.

Returns

Nothing.

Notes

If a Mesh wasn't created with a custom vertex format, it will have 3 vertex attributes named VertexPosition, VertexTexCoord, and VertexColor.

Custom named attributes can be accessed in a vertex shader by declaring them as attribute vec4 MyCustomAttribute at the top-level of the vertex shader code. The name must match what was specified in the vertex format and in the name argument to Mesh:attachAttribute.

See Also

Other Languages