Describes the memory layout of VertexData instances, as used for every single vertex.

The format is set up via a simple String. Here is an example:

    					format = VertexDataFormat.fromString("position:number2, 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 VertexData

### Hierarchy

- VertexDataFormat

## Index

### Constructors

- constructor

### Properties

- formatString
- numAttributes
- vertexSize
- vertexSizeIn32Bits

### Methods

- extend
- getFormat
- getName
- getOffset
- getOffsetIn32Bits
- getSize
- getSizeIn32Bits
- get_formatString
- get_numAttributes
- get_vertexSize
- get_vertexSizeIn32Bits
- hasAttribute
- setVertexBufferAt
- toString
- fromString

## Constructors

### constructor

- new VertexDataFormat(): VertexDataFormat

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:36

  Don't use the constructor, but call `VertexDataFormat.fromString` instead. This allows for efficient format caching.

  #### Returns VertexDataFormat

## Properties

### formatString

formatString: string

- Defined in lib/starling/rendering/VertexDataFormat.d.ts:112

Returns the normalized format string.

### numAttributes

numAttributes: number

- Defined in lib/starling/rendering/VertexDataFormat.d.ts:124

The number of attributes per vertex.

### vertexSize

vertexSize: number

- Defined in lib/starling/rendering/VertexDataFormat.d.ts:116

The size (in bytes) of each vertex.

### vertexSizeIn32Bits

vertexSizeIn32Bits: number

- Defined in lib/starling/rendering/VertexDataFormat.d.ts:120

The size (in 32 bit units) of each vertex.

## Methods

### extend

- extend(format: string): VertexDataFormat

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:72

  Creates a new VertexDataFormat instance by appending the given format string to the current instance's format.

  #### Parameters

  - ##### format: string

  #### Returns VertexDataFormat

### getFormat

- getFormat(attrName: string): string

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:90

  Returns the format of a certain vertex attribute, identified by its name. Typical values: `float1, float2, float3, float4, bytes4`.

  #### Parameters

  - ##### attrName: string

  #### Returns string

### getName

- getName(attrIndex: number): string

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:93

  Returns the name of the attribute at the given position within the vertex format.

  #### Parameters

  - ##### attrIndex: number

  #### Returns string

### getOffset

- getOffset(attrName: string): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:83

  Returns the offset (in bytes) of an attribute within a vertex.

  #### Parameters

  - ##### attrName: string

  #### Returns number

### getOffsetIn32Bits

- getOffsetIn32Bits(attrName: string): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:86

  Returns the offset (in 32 bit units) of an attribute within a vertex.

  #### Parameters

  - ##### attrName: string

  #### Returns number

### getSize

- getSize(attrName: string): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:77

  Returns the size of a certain vertex attribute in bytes.

  #### Parameters

  - ##### attrName: string

  #### Returns number

### getSizeIn32Bits

- getSizeIn32Bits(attrName: string): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:80

  Returns the size of a certain vertex attribute in 32 bit units.

  #### Parameters

  - ##### attrName: string

  #### Returns number

### Protected get_formatString

- get_formatString(): string

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:113

  #### Returns string

### Protected get_numAttributes

- get_numAttributes(): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:125

  #### Returns number

### Protected get_vertexSize

- get_vertexSize(): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:117

  #### Returns number

### Protected get_vertexSizeIn32Bits

- get_vertexSizeIn32Bits(): number

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:121

  #### Returns number

### hasAttribute

- hasAttribute(attrName: string): boolean

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:96

  Indicates if the format contains an attribute with the given name.

  #### Parameters

  - ##### attrName: string

  #### Returns boolean

### setVertexBufferAt

- setVertexBufferAt(index: number, buffer: VertexBuffer3D, attrName: string): void

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:104

  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: number

  - ##### buffer: VertexBuffer3D

  - ##### attrName: string

  #### Returns void

### toString

- toString(): string

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:107

  Returns the normalized format string.

  #### Returns string

### Static fromString

- fromString(format: string): VertexDataFormat

- - Defined in lib/starling/rendering/VertexDataFormat.d.ts:68

  Creates a new VertexDataFormat instance from the given String, or returns one from the cache (if an equivalent String has already been used before).

  @param format

  Describes the attributes of each vertex, consisting of a comma-separated list of attribute names and their format, e.g.:

      "position:number2, texCoords:number2, color:bytes4"

  This set of attributes will be allocated for each vertex, and they will be stored in exactly the given order.

  - Names are used to access the specific attributes of a vertex. They are completely arbitrary.
  - The available formats can be found in the `Context3DVertexBufferFormat` class in the `flash.display3D` package.
  - Both names and format strings are case-sensitive.
  - Always use `bytes4` for color data that you want to access with the respective methods.
  - Furthermore, the attribute names of colors should include the string "color" (or the uppercase variant). If that's the case, the "alpha" channel of the color will automatically be initialized with "1.0" when the VertexData object is created or resized.

  #### Parameters

  - ##### format: string

  #### Returns VertexDataFormat

Generated using TypeDoc