Package | starling.rendering |
Class | public class VertexDataFormat |
Inheritance | VertexDataFormat Object |
The format is set up via a simple String. Here is an example:
format = VertexDataFormat.fromString("position:float2, color:bytes4");
This String describes two attributes: "position" and "color". The keywords after
the colons depict the format and size of the data that each attribute uses; in this
case, we store two floats for the position (taking up the x- and y-coordinates) and four
bytes for the color. (The available formats are the same as those defined in the
Context3DVertexBufferFormat
class:
float1, float2, float3, float4, bytes4
.)
You cannot create a VertexData instance with its constructor; instead, you must use the
static fromString
-method. The reason for this behavior: the class maintains
a cache, and a call to fromString
will return an existing instance if an
equivalent format has already been created in the past. That saves processing time and
memory.
VertexDataFormat instances are immutable, i.e. they are solely defined by their format string and cannot be changed later.
See also
Property | Defined By | ||
---|---|---|---|
formatString : String [read-only] Returns the normalized format string. | VertexDataFormat | ||
numAttributes : int [read-only] The number of attributes per vertex. | VertexDataFormat | ||
vertexSize : int [read-only] The size (in bytes) of each vertex. | VertexDataFormat | ||
vertexSizeIn32Bits : int [read-only] The size (in 32 bit units) of each vertex. | VertexDataFormat |
Method | Defined By | ||
---|---|---|---|
Don't use the constructor, but call VertexDataFormat.fromString instead. | VertexDataFormat | ||
extend(format:String):VertexDataFormat Creates a new VertexDataFormat instance by appending the given format string
to the current instance's format. | VertexDataFormat | ||
fromString(format:String):VertexDataFormat [static] Creates a new VertexDataFormat instance from the given String, or returns one from
the cache (if an equivalent String has already been used before). | VertexDataFormat | ||
getFormat(attrName:String):String Returns the format of a certain vertex attribute, identified by its name. | VertexDataFormat | ||
getName(attrIndex:int):String Returns the name of the attribute at the given position within the vertex format. | VertexDataFormat | ||
getOffset(attrName:String):int Returns the offset (in bytes) of an attribute within a vertex. | VertexDataFormat | ||
getOffsetIn32Bits(attrName:String):int Returns the offset (in 32 bit units) of an attribute within a vertex. | VertexDataFormat | ||
getSize(attrName:String):int Returns the size of a certain vertex attribute in bytes. | VertexDataFormat | ||
getSizeIn32Bits(attrName:String):int Returns the size of a certain vertex attribute in 32 bit units. | VertexDataFormat | ||
hasAttribute(attrName:String):Boolean Indicates if the format contains an attribute with the given name. | VertexDataFormat | ||
setVertexBufferAt(index:int, buffer:VertexBuffer3D, attrName:String):void Specifies which vertex data attribute corresponds to a single vertex shader
program input. | VertexDataFormat | ||
toString():String Returns the normalized format string. | VertexDataFormat |
formatString | property |
formatString:String
[read-only] Returns the normalized format string.
public function get formatString():String
numAttributes | property |
numAttributes:int
[read-only] The number of attributes per vertex.
public function get numAttributes():int
vertexSize | property |
vertexSize:int
[read-only] The size (in bytes) of each vertex.
public function get vertexSize():int
vertexSizeIn32Bits | property |
vertexSizeIn32Bits:int
[read-only] The size (in 32 bit units) of each vertex.
public function get vertexSizeIn32Bits():int
VertexDataFormat | () | Constructor |
public function VertexDataFormat()
Don't use the constructor, but call VertexDataFormat.fromString
instead.
This allows for efficient format caching.
extend | () | method |
public function extend(format:String):VertexDataFormat
Creates a new VertexDataFormat instance by appending the given format string to the current instance's format.
Parameters
format:String |
VertexDataFormat |
fromString | () | method |
public static function fromString(format:String):VertexDataFormat
Creates a new VertexDataFormat instance from the given String, or returns one from the cache (if an equivalent String has already been used before).
Parameters
format:String — Describes the attributes of each vertex, consisting of a comma-separated
list of attribute names and their format, e.g.:
"position:float2, texCoords:float2, color:bytes4" This set of attributes will be allocated for each vertex, and they will be stored in exactly the given order.
|
VertexDataFormat |
getFormat | () | method |
public function getFormat(attrName:String):String
Returns the format of a certain vertex attribute, identified by its name.
Typical values: float1, float2, float3, float4, bytes4
.
Parameters
attrName:String |
String |
getName | () | method |
public function getName(attrIndex:int):String
Returns the name of the attribute at the given position within the vertex format.
Parameters
attrIndex:int |
String |
getOffset | () | method |
public function getOffset(attrName:String):int
Returns the offset (in bytes) of an attribute within a vertex.
Parameters
attrName:String |
int |
getOffsetIn32Bits | () | method |
public function getOffsetIn32Bits(attrName:String):int
Returns the offset (in 32 bit units) of an attribute within a vertex.
Parameters
attrName:String |
int |
getSize | () | method |
public function getSize(attrName:String):int
Returns the size of a certain vertex attribute in bytes.
Parameters
attrName:String |
int |
getSizeIn32Bits | () | method |
public function getSizeIn32Bits(attrName:String):int
Returns the size of a certain vertex attribute in 32 bit units.
Parameters
attrName:String |
int |
hasAttribute | () | method |
public function hasAttribute(attrName:String):Boolean
Indicates if the format contains an attribute with the given name.
Parameters
attrName:String |
Boolean |
setVertexBufferAt | () | method |
public function setVertexBufferAt(index:int, buffer:VertexBuffer3D, attrName:String):void
Specifies which vertex data attribute corresponds to a single vertex shader
program input. This wraps the Context3D
-method with the same name,
automatically replacing attrName
with the corresponding values for
bufferOffset
and format
.
Parameters
index:int | |
buffer:VertexBuffer3D | |
attrName:String |
toString | () | method |
public function toString():String
Returns the normalized format string.
ReturnsString |